LeetCode 47, Medium. Topics: Array, Backtracking, Sorting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:
Problem
Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.
Examples
Constraints
1 <= nums.length <= 8
-10 <= nums[i] <= 10
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode 250, NeetCode All. Last modified on September 7, 2026