Problem
You get an array nums of different integers. Return all the permutations of nums. A permutation is an ordering of all the items of the array.
You can return the permutations in any order. Inside each permutation, the order of the items is important.
Example 1
- Input:
- nums = [8,1]
- Output:
- [[8,1],[1,8]]
Example 2
- Input:
- nums = [4,0,6]
- Output:
- [[4,0,6],[4,6,0],[0,4,6],[0,6,4],[6,4,0],[6,0,4]]
- Explanation:
- Three different items have
3 * 2 * 1 = 6orderings.
Example 3
- Input:
- nums = [-2]
- Output:
- [[-2]]
Constraints
- 1 <= nums.length <= 6
- -10 <= nums[i] <= 10
- All the numbers in nums are different.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Meta
Leetcode 46. Permutations
Reported Jan 14, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source