全排列

Given a collection of distinct integers, return all possible permutations.

Example:

Input: [1,2,3]
Output:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]
思路:反复交换,直到最后一位数字。

 


posted @ 2019-03-19 11:06  zzas12345  阅读(140)  评论(0编辑  收藏  举报