> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/47-permutations-ii.md).

# 47. Permutations II

## Medium

***

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

&#x20;

**Example 1:**

<pre><code>Input: nums = [1,1,2]
<strong>Output:
</strong>[[1,1,2],
 [1,2,1],
 [2,1,1]]
</code></pre>

**Example 2:**

<pre><code>Input: nums = [1,2,3]
<strong>Output:
</strong> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
</code></pre>

&#x20;

**Constraints:**

* `1 <= nums.length <= 8`
* `-10 <= nums[i] <= 10`
