{
  "type": "code_options",
  "author": "https://github.com/begeekmyfriend/leetcode",
  "source": "solution.md",
  "exercise_id": "e9241eeeec6b4b34895f4660e3c63ec1",
  "keywords": "数组,回溯",
  "title": "全排列",
  "desc": [
    {
      "content": "\n<p>给定一个<strong> 没有重复</strong> 数字的序列，返回其所有可能的全排列。</p><p><strong>示例:</strong></p><pre><strong>输入:</strong> [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>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <bits/stdc++.h>\nusing namespace std;\nclass Solution\n{\npublic:\n\tvector<vector<int>> permute(vector<int> &nums)\n\t{\n\t\tvector<vector<int>> res;\n\t\tvector<bool> used(nums.size());\n\t\tdfs(nums, used, res);\n\t\treturn res;\n\t}\nprivate:\n\tvector<int> stack;\n\tvoid dfs(vector<int> &nums, vector<bool> &used, vector<vector<int>> &res)\n\t{\n\t\tif (stack.size() == nums.size())\n\t\t{\n\t\t\tres.push_back(stack);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (int i = 0; i < nums.size(); i++)\n\t\t\t{\n\t\t\t\tif (!used[i])\n\t\t\t\t{\n\t\t\t\t\tused[i] = true;\n\t\t\t\t\tstack.push_back(nums[i]);\n\t\t\t\t\tdfs(nums, used, res);\n\t\t\t\t\tstack.pop_back();\n\t\t\t\t\tused[i] = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};",
    "language": "cpp"
  },
  "node_id": "dailycode-6c74549bf696457084ef66af3c8ab6e0",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600469820"
}