GitBook: [#2] No subject

This commit is contained in:
Cores
2022-01-07 09:00:01 +00:00
committed by gitbook-bot
parent 456ff183d5
commit fa872a22b7
119 changed files with 4436 additions and 5678 deletions

View File

@ -2,13 +2,14 @@
## 题目链接
[牛客网](https://www.nowcoder.com/practice/ef1f53ef31ca408cada5093c8780f44b?tpId=13&tqId=11166&tab=answerKey&from=cyc_github)
[牛客网](https://www.nowcoder.com/practice/ef1f53ef31ca408cada5093c8780f44b?tpId=13\&tqId=11166\&tab=answerKey\&from=cyc\_github)
## 题目描述
需要保证奇数和奇数偶数和偶数之间的相对位置不变这和书本不太一样例如对于 [1,2,3,4,5]调整后得到 [1,3,5,2,4]而不能是 {5,1,3,4,2} 这种相对位置改变的结果
需要保证奇数和奇数偶数和偶数之间的相对位置不变这和书本不太一样例如对于 \[1,2,3,4,5]调整后得到 \[1,3,5,2,4]而不能是 {5,1,3,4,2} 这种相对位置改变的结果
![](https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/d03a2efa-ef19-4c96-97e8-ff61df8061d3.png)\
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/d03a2efa-ef19-4c96-97e8-ff61df8061d3.png" width="200px"> </div><br>
## 解题思路
@ -37,7 +38,7 @@ private boolean isEven(int x) {
}
```
方法二使用冒泡思想每次都将当前偶数上浮到当前最右边时间复杂度 O(N<sup>2</sup>)空间复杂度 O(1)时间换空间
方法二使用冒泡思想每次都将当前偶数上浮到当前最右边时间复杂度 O(N2)空间复杂度 O(1)时间换空间
```java
public int[] reOrderArray(int[] nums) {