We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1b8c19b commit 9a150d9Copy full SHA for 9a150d9
Methodology/31. 下一个排列.md
@@ -49,7 +49,7 @@
49
算法步骤:
50
51
1. 从后往前找到第一个升序的元素对,分别定义其下标为 `index - 1` 和 `index`,即 `nums[index - 1] < nums[i]`
52
-2. 重新从后往前找到第一个大于 `nums[index - 1]` 的元素,定义其下标为 `i`, 即元素为 `nums[i]` 并交换 `nums[index - 1]`
+2. 重新从后往前找到第一个大于 `nums[index - 1]` 的元素,定义其下标为 `i`, 即元素为 `nums[i]` 并交换 `nums[index - 1]`,注意此时不一定能找到,因此也不一定发生交换,所以不能从前往后找。
53
3. 接着反转 `[index , n - 1]` 范围内的所有元素,因为 `[index, n - 1]` 范围内的元素经过第一步筛选后一定是非升序的,下一个更大的排列一定是升序的。
54
55
```Java
0 commit comments