We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04c5eef commit 4be202fCopy full SHA for 4be202f
algorithms/cpp/nextPermutation/nextPermutation.cpp
@@ -33,11 +33,11 @@
33
* 2 1 3 4
34
* ...
35
*
36
- * The pattern as below:
+ * The pattern can be descripted as below:
37
38
- * 1) find the first place which num[i-1] < num[i]
39
- * 2) find the first number from n-1 to i which >= num[i-1]
40
- * 3) swap the 2) num with num[i-1]
+ * 1) from n-1 to 0, find the first place [i-1] which num[i-1] < num[i]
+ * 2) from n-1 to i, find the first number from n-1 to i which >= num[i-1]
+ * 3) swap the 2) num with the num[i-1]
41
* 4) sort the sub-array [i, n) //actuall sort is fine as well
42
43
* For example:
0 commit comments