ntree.aiPermutations
Permutations
mediumsolvedattempted
You are given an array of distinct integers nums.
Return all possible permutations of it. The answer may be returned in any order.
Example 1:
Input: nums = [2, 5, 9]
Output: [[2, 5, 9], [2, 9, 5], [5, 2, 9], [5, 9, 2], [9, 2, 5], [9, 5, 2]]
Example 2:
Input: nums = [0, 1]
Output: [[0, 1], [1, 0]]
Constraints:
1 <= length of nums <= 6-10 <= nums[i] <= 10- All the elements of
numsare different
def permute(nums: list[int]) -> list[list[int]]: pass Press Visualise to step through your code.