Back to course home
0% completed
Vote For New Content
Permutations II (medium)
Problem Statement
Given a list of numbers nums
that might have duplicates, return all unique arrangements of the numbers in any order.
Examples
Example 1:
- Input: nums = [1, 2, 2]
- Output: [[1,2,2],[2,1,2],[2,2,1]]
- Explanation: There are a total of 6 permutations of [1, 2, 2] list but only 3 are unique.
Example 2:
- Input: nums = [2, 2, 3]
- Output: [[2,2,3],[2,3,2],[3,2,2]]
- Explanation: All unique permutations of the list [2, 2, 3] are shown above.
Example 3:
- Input: nums = [1, 2, 2, 3]
- Output: [[1,2,2,3],[1,2,3,2],[1,3,2,2],[2,1,2,3],[2,1,3,2],[2,2,1,3],[2,2,3,1],[2,3,1,2],[2,3,2,1],[3,1,2,2],[3,2,1,2],[3,2,2,1]]
- Explanation: All unique permutations of the list [1, 2, 2, 3] are shown above.
Constraints:
- 1 <= nums.length <= 8
- -10 <= nums[i] <= 10
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible