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;