当前位置:网站首页>剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
2022-07-02 14:21:00 【anieoo】
原题链接:剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
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;
}
};
边栏推荐
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- DGraph: 大规模动态图数据集
- AP and F107 data sources and processing
- Interview summary of large factories
- 宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
- 上传代码到远程仓库报错error: remote origin already exists.
- 一文看懂:数据指标体系的4大类型
- Résumé de l'entrevue de Dachang Daquan
- Serial port controls steering gear rotation
- pwm呼吸燈
猜你喜欢
使用知行之桥的API端口,提供资源供合作伙伴访问
Easy language ABCD sort
LeetCode 2. 两数相加
隐私计算技术创新及产业实践研讨会:学习
Download blender on Alibaba cloud image station
Error when uploading code to remote warehouse: remote origin already exists
【Leetcode】13. Roman numeral to integer
LeetCode 1. Sum of two numbers
机器学习-感知机模型
The macrogenome microbiome knowledge you want is all here (2022.7)
随机推荐
Global and Chinese markets of stainless steel surgical suture 2022-2028: Research Report on technology, participants, trends, market size and share
C语言自定义函数的方法
学习周刊-总第60期-2022年第25周
Tech talk activity preview | building intelligent visual products based on Amazon kVs
Detailed explanation of @accessories annotation of Lombok plug-in
System Verilog实现优先级仲裁器
Go zero micro service practical series (VIII. How to handle tens of thousands of order requests per second)
寒门再出贵子:江西穷县考出了省状元,做对了什么?
大厂面试总结大全
pwm呼吸灯
【Leetcode】14. Longest Common Prefix
Global and Chinese market of oil analyzers 2022-2028: Research Report on technology, participants, trends, market size and share
有赞和腾讯云、阿里云一同摘得“中国企业云科技服务商50强”[通俗易懂]
VMware install win10 image
Executive engine module of high performance data warehouse practice based on Impala
Global and Chinese markets for carbon dioxide laser cutting heads 2022-2028: Research Report on technology, participants, trends, market size and share
一文看懂:数据指标体系的4大类型
P6774 [noi2020] tears in the era (block)
二、mock平台的扩展
移动应用性能工具探索之路