43. Permutations II

MediumBacktracking

Given a collection of numbers, `nums`, that might contain duplicates, return all possible **unique permutations** in **any order**.

Examples

Input: [1,1,2]

Output: [[1,1,2],[1,2,1],[2,1,1]]

Explanation: Three distinct arrangements; the duplicate 1s are consumed left-to-right to avoid repeats.

Constraints

  • 1 <= nums.length <= 8
  • -10 <= nums[i] <= 10
Loading...

Run checks all cases above. Submit evaluates all test cases.