46. Permutations
Practice Permutations for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given an array of distinct integers, return every possible ordering of its elements. The permutations can be in any order.
Example
nums = [1,2,3] -> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Constraints
- 1 <= nums.length <= 6