46. Permutations(unsolved)

来源:互联网 发布:淘宝主图背景图片大全 编辑:程序博客网 时间:2024/06/07 04:53

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]
]

解答:这道题我理解得不是很深刻。其实主要的思想在于交换两个数,直到所有数都遍历了。

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]]
0 0
原创粉丝点击