Skip to content

Commit 3cf1881

Browse files
committed
add permutations ii
1 parent ad11b79 commit 3cf1881

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

permutations-ii/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
## Variant of [Next Permutation](../next-permutation)
12

2-
## TODO
3-
* write down thinking
3+
With the help of [Next Permutation](../next-permutation), you can find all unique permutations from the first permutation.
44

5+
### First and Last
6+
7+
* First permutation is the numbers in non-descending order
8+
* Last permutation is the numbers in non-ascending order
9+
10+
11+
so the code is like
12+
13+
```
14+
sort(num) // make it the first
15+
16+
17+
while num is not the last
18+
call nextPermutation(num)
19+
20+
copy num into result
21+
22+
23+
```

0 commit comments

Comments
 (0)