当前位置:网站首页>An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
2022-08-09 13:54:00 【to raise pigs】
class Solution {
public int[] exchange(int[] nums) {
int n = nums.length;
int i = -1, j = 0;
for(; j < n; j++) {
if(nums[j] % 2 == 1) {
int t = nums[++i];
nums[i] = nums[j];
nums[j] = t;
}
}
return nums;
}
}
边栏推荐
- 正则表达式-re模块
- 陈强教授《机器学习及R应用》课程 第十七章作业
- 电脑重装系统还原0x80070005错误如何解决
- FFmpeg多媒体文件处理(ffmpeg处理流数据的基本概念)
- Unicom network management protocol block diagram
- 搭建大型分布式服务(二)搭建会员服务
- Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
- 现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
- GIN file upload and return
- 记录本项目中用到的系统调用与C库函数-2
猜你喜欢

某高校的R语言数据分析期末作业

FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)

error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma

kustomize entry example and basic syntax instructions

联通网管协议框图

快来扔鸡蛋。

19、学习MySQL 索引

Oracle Recovery Tools修复空闲坏块

Periodic sharing of Alibaba Da Tao system model governance

5G China unicom repeater network management protocol real-time requirements
随机推荐
Redis源码剖析之字典(dict)
GIN初探,环境安装
Explanation of RTSP protocol
Data Mining-06
某高校的R语言数据分析期末作业
leetcode 20. Valid Parentheses 有效的括号(中等)
联通网管协议框图
面试题精选:神奇的斐波那契数列
ArcEngine(九)图形绘制
ARM board adds routing function
5G China unicom AP:B SMS ASCII 转码要求
正则表达式-re模块
[HCIP Continuous Update] Principle and Configuration of IS-IS Protocol
FFmpeg multimedia file processing (implementation of ffmpeg operation directory and list)
GIN file upload and return
电脑重装系统后桌面图标如何调小尺寸
ftplib+ tqdm upload and download progress bar
gin's middleware and routing grouping
Redis源码剖析之数据过期(expire)
十进制数字→十六进制字符