algorythms
Subsets / Combinations
LC #46Medium

Permutations

Subsets / Combinations
AmazonGoogleMetaLinkedInMicrosoft

Problem

Return all possible permutations of an array of distinct integers.

arraybacktracking

Constraints

  • 1 ≤ n ≤ 6
  • -10 ≤ nums[i] ≤ 10
  • All values are unique

Example

Inputnums = [1, 2, 3]
Output[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Why

3! = 6 permutations. Return in any order

Hints — reveal one at a time