46. Permutations
2016-12-16 本文已影响0人
我是你的果果呀
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开始扫描, 如果子串里含有当前数字, 则继续,不递归, 否则将当前值加入到子串中,递归,回溯。
