47. Permutations II

Practice Permutations II for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

nums may contain duplicates. Return every distinct ordering of its elements. The permutations can be listed in any order.

Example

nums = [1,1,2]  ->  [[1,1,2],[1,2,1],[2,1,1]]

Constraints