Problem 60: Permutation Sequence
Last updated
Was this helpful?
Last updated
Was this helpful?
基本的思路:
1) For n numbers, permutations can be divided into n groups with (n - 1)! elements in each group. 2) Thus, k / (n - 1)! is the group index among the current n (to be) sorted groups;3) and k % (n - 1)! is the sequence number k for next iteration.
这个讲解不错
用 LinkedList 把元素存好,然后一个一个地取出来
for 循环 k-- 相当于是 k = k - 1;