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

畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权

寒门再出贵子:江西穷县考出了省状元,做对了什么?

Exploration and practice of integration of streaming and wholesale in jd.com

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

深度之眼(三)——矩阵的行列式

Ap和F107数据来源及处理

AP and F107 data sources and processing

Geoserver: publishing PostGIS data sources

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

OpenPose的使用
随机推荐
Talk about an experience of job hopping and being rejected
QWebEngineView崩溃及替代方案
Serial port controls steering gear rotation
Does digicert SSL certificate support Chinese domain name application?
亚马逊云科技 Community Builder 申请窗口开启
How openharmony starts FA of remote devices
uboot的作用和功能
超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业
C语言自定义函数的方法
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
对接保时捷及3PL EDI案例
Seven charts, learn to do valuable business analysis
一年頂十年
P6774 [NOI2020] 时代的眼泪(分块)
基于Impala的高性能数仓实践之执行引擎模块
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
电脑自带软件使图片底色变为透明(抠图白底)
Tech talk activity preview | building intelligent visual products based on Amazon kVs
只是巧合?苹果iOS16的神秘技术竟然与中国企业5年前产品一致!
深度之眼(二)——矩阵及其基本运算