Permutations(improve)

来源:互联网 发布:淘宝买家采集 编辑:程序博客网 时间:2024/04/28 22:08

Given a collection of 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], and [3,2,1].


I can not think of how to solve this problem in a elegant way. I know it needs to be done recursively, while... it will for sure takes me a lot of time to consider. Anyway, this is really a good piece of code!

0 0