given a collection of numbers, return all possible permutations.
for example,
<code>[1,2,3]</code> have the following permutations:
<code>[1,2,3]</code>, <code>[1,3,2]</code>, <code>[2,1,3]</code>, <code>[2,3,1]</code>, <code>[3,1,2]</code>,
and <code>[3,2,1]</code>.
分析:暂时不用考虑重复元素问题。
思路一:排列问题一般可以用递归进行解决,先从序列中抽出一个数,将其余的树进行排列,然后依次插入得到的排列的位置即可得到结果。如[1, 2, 3]先将1抽出,得到[2, 3]的排列结果:[2, 3] 与 [3, 2], 然后将1插入到[2, 3]以及[3, 2]的各个位置。
思路二:如果允许,可以直接使用stl里面的next_permutation;