46. Permutations

Given a collection of distinct numbers, return all possible permutations.

For example,
[1,2,3]have the following permutations:
[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ]

backtracking  子串长度够了就加到返回list 里, 始终从0开始扫描, 如果子串里含有当前数字, 则继续,不递归, 否则将当前值加入到子串中,递归,回溯。

46. Permutations_第1张图片

你可能感兴趣的:(46. Permutations)