当前位置:网站首页>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;
}
};边栏推荐
- Executive engine module of high performance data warehouse practice based on Impala
- Masa framework - DDD design (1)
- Ap和F107数据来源及处理
- 智能垃圾桶(五)——点亮OLED
- The macrogenome microbiome knowledge you want is all here (2022.7)
- Learning Weekly - total issue 60 - 25th week of 2022
- OpenPose的使用
- 【Leetcode】13. Roman numeral to integer
- [essay solicitation activity] Dear developer, RT thread community calls you to contribute
- Kubernetes three open interfaces first sight
猜你喜欢

【Leetcode】14. 最長公共前綴

MOSFET器件手册关键参数解读

绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东

剑指 Offer 22. 链表中倒数第k个节点
![John blasting appears using default input encoding: UTF-8 loaded 1 password hash (bcrypt [blowfish 32/64 x3])](/img/4c/ddf7f8085257d0eb8766dbec251345.png)
John blasting appears using default input encoding: UTF-8 loaded 1 password hash (bcrypt [blowfish 32/64 x3])

Error when uploading code to remote warehouse: remote origin already exists

Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes

Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP

【Leetcode】13. Roman numeral to integer

Seven charts, learn to do valuable business analysis
随机推荐
The macrogenome microbiome knowledge you want is all here (2022.7)
剑指 Offer 27. 二叉树的镜像
Domestic relatively good OJ platform [easy to understand]
Method of C language self defining function
In MySQL and Oracle, the boundary and range of between and precautions when querying the date
【Leetcode】14. 最长公共前缀
【Leetcode】13. Roman numeral to integer
&lt;四&gt; H264解码输出yuv文件
如何与博格华纳BorgWarner通过EDI传输业务数据?
Does digicert SSL certificate support Chinese domain name application?
Leetcode1380: lucky numbers in matrix
一年頂十年
OpenPose的使用
Kubernetes three open interfaces first sight
IP address translation address segment
Learning Weekly - total issue 60 - 25th week of 2022
13、Darknet YOLO3
Tech talk activity preview | building intelligent visual products based on Amazon kVs
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
What is generics- Introduction to generics