46. Permutations 全排列

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

List<Integer>的大小是size()
permutations,remove的是最后一位。(permutations.size() - 1);
results.add(new ArrayList<>(permutations));

猜你喜欢

转载自www.cnblogs.com/immiao0319/p/13190182.html