Medium · Backtracking

Permutations

You are given a list of distinct whole numbers. Return every order the numbers can be arranged in.

  • Every number appears once.
  • The arrangements can be listed in any order.
  • Three numbers have six arrangements, four have twenty-four.
nums = [1, 2, 3]

→ [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
Record your take

No one has solved it yet.