当前位置:网站首页>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;
}
};边栏推荐
- Notice on holding a salon for young editors of scientific and Technological Journals -- the abilities and promotion strategies that young editors should have in the new era
- 一年顶十年
- The macrogenome microbiome knowledge you want is all here (2022.7)
- Un an à dix ans
- 深度之眼(三)——矩阵的行列式
- 博客主题 “Text“ 夏日清新特别版
- 配置基于接口的ARP表项限制和端口安全(限制用户私自接入傻瓜交换机或非法主机接入)
- 关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...
- Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
- John blasting appears using default input encoding: UTF-8 loaded 1 password hash (bcrypt [blowfish 32/64 x3])
猜你喜欢

福元医药上交所上市:市值105亿 胡柏藩身价超40亿

易语言abcd排序

Believe in yourself and finish the JVM interview this time

PhD Debate-11 预告 | 回顾与展望神经网络的后门攻击与防御

Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...

剑指 Offer 22. 链表中倒数第k个节点

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

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

Executive engine module of high performance data warehouse practice based on Impala

Hard core! One configuration center for 8 classes!
随机推荐
john爆破出现Using default input encoding: UTF-8 Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Connect Porsche and 3PL EDI cases
Tech talk activity preview | building intelligent visual products based on Amazon kVs
VMware安装win10镜像
七张图,学会做有价值的经营分析
JS delete substring in string
Notice on holding a salon for young editors of scientific and Technological Journals -- the abilities and promotion strategies that young editors should have in the new era
Go zero micro service practical series (VIII. How to handle tens of thousands of order requests per second)
一年顶十年
二、mock平台的扩展
linux安装postgresql + patroni 集群问题
关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...
Seven charts, learn to do valuable business analysis
【Leetcode】13. Roman numeral to integer
How to transfer business data with BorgWarner through EDI?
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
Usage of sprintf() function in C language
Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品
Changwan group rushed to Hong Kong stocks: the annual revenue was 289million, and Liu Hui had 53.46% voting rights
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO