当前位置:网站首页>Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
2022-07-02 17:12:00 【anieoo】
Original link : The finger of the sword Offer 21. Adjust the array order so that the odd Numbers precede the even Numbers
solution:
class Solution {
public:
vector<int> exchange(vector<int>& nums) {
int n = nums.size();
for(int i = 0,j = 0;i < n;i++) {
if(nums[i] % 2 != 0) swap(nums[i],nums[j++]);
}
return nums;
}
};边栏推荐
- Masa framework - DDD design (1)
- 【Leetcode】14. 最长公共前缀
- linux下配置Mysql授权某个用户远程访问,不受ip限制
- &lt;四&gt; H264解码输出yuv文件
- [leetcode] 14. Préfixe public le plus long
- Exploration and practice of integration of streaming and wholesale in jd.com
- 一年頂十年
- P6774 [NOI2020] 时代的眼泪(分块)
- 伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
- 宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
猜你喜欢

Digital IC hand tearing code -- voting device

【Leetcode】13. 罗马数字转整数

綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東

移动应用性能工具探索之路

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面

How to transfer business data with BorgWarner through EDI?

【Leetcode】14. Longest Common Prefix

Easy language ABCD sort

Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion

PWM controlled steering gear
随机推荐
Ap和F107数据来源及处理
Executive engine module of high performance data warehouse practice based on Impala
Use the API port of the bridge of knowledge and action to provide resources for partners to access
lsf基础命令
AP and F107 data sources and processing
What will you do after digital IC Verification?
Exploration of mobile application performance tools
[essay solicitation activity] Dear developer, RT thread community calls you to contribute
有赞和腾讯云、阿里云一同摘得“中国企业云科技服务商50强”[通俗易懂]
Error when uploading code to remote warehouse: remote origin already exists
社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东
Rock PI Development Notes (II): start with rock PI 4B plus (based on Ruixing micro rk3399) board and make system operation
剑指 Offer 26. 树的子结构
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
L'explosion de John utilise l'encodage d'entrée par défaut: UTF - 8 Loaded 1 password Hash (bcrypt [blowfish 32 / 64 X3])
Linux Installation PostgreSQL + Patroni cluster problem
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
2、 Expansion of mock platform
【Leetcode】14. 最長公共前綴
学习周刊-总第60期-2022年第25周