Math Fundamentals18 sections · 814 units
Open in Course

Problem - Permutations II

(LeetCode 47)

You are given an array of integers that may contain duplicates. Return all unique permutations.

Example: [1,1,2] has 3 unique permutations: [1,1,2], [1,2,1], [2,1,1].

If you treat duplicates as distinct, you'd get 6 permutations (some identical). You must skip duplicates during backtracking.

Try it yourself first.