当前位置:网站首页>剑指 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;
}
};边栏推荐
- Error when uploading code to remote warehouse: remote origin already exists
- What is the difference between JSP and servlet?
- [error record] error -32000 received from application: there are no running service protocol
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- MOSFET器件手册关键参数解读
- In MySQL and Oracle, the boundary and range of between and precautions when querying the date
- uboot的作用和功能
- 绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
- 上传代码到远程仓库报错error: remote origin already exists.
- PWM breathing lamp
猜你喜欢

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

Interview summary of large factories

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

小鹏P7雨天出事故安全气囊没有弹出 官方回应:撞击力度未达到弹出要求

Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))

Serial port controls steering gear rotation

unity Hub 登錄框變得很窄 無法登錄

一文看懂:数据指标体系的4大类型

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

社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东
随机推荐
linux下配置Mysql授权某个用户远程访问,不受ip限制
Deep learning image data automatic annotation [easy to understand]
【Leetcode】14. 最長公共前綴
PhD Debate-11 预告 | 回顾与展望神经网络的后门攻击与防御
Ap和F107数据来源及处理
R and rstudio download and installation tutorial (super detailed)
Xiaopeng P7 had an accident on rainy days, and the airbag did not pop up. Official response: the impact strength did not meet the ejection requirements
What will you do after digital IC Verification?
[fluent] dart data type list set type (define set | initialize | generic usage | add elements after initialization | set generation function | set traversal)
Global and Chinese market of desktop hot melt equipment 2022-2028: Research Report on technology, participants, trends, market size and share
Executive engine module of high performance data warehouse practice based on Impala
Yyds dry inventory uses thread safe two-way linked list to realize simple LRU cache simulation
GeoServer:发布PostGIS数据源
john爆破出现Using default input encoding: UTF-8 Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
AP and F107 data sources and processing
C语言自定义函数的方法
LeetCode 5. Longest Palindromic Substring
In MySQL and Oracle, the boundary and range of between and precautions when querying the date
IP地址转换地址段