46.Permutations

46. Permutations

题目地址

https://www.lintcode.com/en/problem/permutations/

https://leetcode.com/problems/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]
]

代码

Approach #1 Recursion

Approach #2 Recursion

Approach Backtrack

Approach 3: 字典序

Last updated

Was this helpful?