当前位置:网站首页>剑指 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;
}
};边栏推荐
猜你喜欢

基于Impala的高性能数仓实践之执行引擎模块

使用知行之桥的API端口,提供资源供合作伙伴访问

In MySQL and Oracle, the boundary and range of between and precautions when querying the date

Ap和F107数据来源及处理

DigiCert SSL证书支持中文域名申请吗?

Interpretation of key parameters in MOSFET device manual

TCP congestion control details | 2 background

【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦

Lampe respiratoire PWM

易语言abcd排序
随机推荐
【Leetcode】14. Longest Common Prefix
深度学习图像数据自动标注[通俗易懂]
数字IC手撕代码--投票表决器
Vscode setting delete line shortcut [easy to understand]
Lampe respiratoire PWM
PWM控制舵机
R and rstudio download and installation tutorial (super detailed)
2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
相信自己,这次一把搞定JVM面试
Interpretation of key parameters in MOSFET device manual
Global and Chinese markets for carbon dioxide laser cutting heads 2022-2028: Research Report on technology, participants, trends, market size and share
How openharmony starts FA of remote devices
七张图,学会做有价值的经营分析
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
VMware install win10 image
[error record] error -32000 received from application: there are no running service protocol
Kubernetes three open interfaces first sight
VMware安装win10镜像
JS delete substring in string