{
  "type": "code_options",
  "author": "https://github.com/qiyuangong/leetcode",
  "source": "solution.md",
  "exercise_id": "6e91a9599b784a6887d11d64b628d446",
  "keywords": "数组,回溯",
  "title": "全排列 II",
  "desc": [
    {
      "content": "\n<p>给定一个可包含重复数字的序列 <code>nums</code> ，<strong>按任意顺序</strong> 返回所有不重复的全排列。</p><p> </p><p><strong>示例 1：</strong></p><pre><strong>输入：</strong>nums = [1,1,2]<strong><br />输出：</strong>[[1,1,2], [1,2,1], [2,1,1]]</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>nums = [1,2,3]<strong><br />输出：</strong>[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]</pre><p> </p><p><strong>提示：</strong></p><ul>\t<li><code>1 <= nums.length <= 8</code></li>\t<li><code>-10 <= nums[i] <= 10</code></li></ul>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "from typing import List\nclass Solution:\n\tdef permuteUnique(self, nums: List[int]) -> List[List[int]]:\n\t\tans = []\n\t\tif len(nums) == 0:\n\t\t\treturn\n\t\tif len(nums) == 1:\n\t\t\treturn [nums]\n\t\tfor index,item in enumerate(nums):\n\t\t\tres = nums[:index]+nums[index+1:]\n\t\t\tfor j in self.permuteUnique(res): \n\t\t\t\tans.append(j+[item])\n\t\trel = []\n\t\tfor i in ans:\n\t\t\tif i not in rel:\n\t\t\t\trel.append(i)\n\t\treturn rel\n# %%\ns = Solution()\nprint(s.permuteUnique(nums = [1,2,3]))",
    "language": "python"
  },
  "node_id": "dailycode-3caea3b49b034e598bc0fbc44f533451",
  "license": "csdn.net",
  "created_at": 1637894159,
  "topic_link": "https://bbs.csdn.net/topics/600470224"
}