{
  "type": "code_options",
  "author": "https://github.com/begeekmyfriend/leetcode",
  "source": "solution.md",
  "exercise_id": "600f400ce85d47949ee960dbfe2501ac",
  "keywords": "位运算,数组,回溯",
  "title": "子集",
  "desc": [
    {
      "content": "\n<p>给你一个整数数组 <code>nums</code> ，数组中的元素 <strong>互不相同</strong> 。返回该数组所有可能的子集（幂集）。</p><p>解集 <strong>不能</strong> 包含重复的子集。你可以按 <strong>任意顺序</strong> 返回解集。</p><p> </p><p><strong>示例 1：</strong></p><pre><strong>输入：</strong>nums = [1,2,3]<strong><br />输出：</strong>[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>nums = [0]<strong><br />输出：</strong>[[],[0]]</pre><p> </p><p><strong>提示：</strong></p><ul>\t<li><code>1 <= nums.length <= 10</code></li>\t<li><code>-10 <= nums[i] <= 10</code></li>\t<li><code>nums</code> 中的所有元素 <strong>互不相同</strong></li></ul>",
      "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>> subsets(vector<int> &nums)\n\t{\n\t\tvector<vector<int>> res;\n\t\tdfs(nums, 0, res);\n\t\treturn res;\n\t}\nprivate:\n\tvector<int> stack;\n\tvoid dfs(vector<int> &nums, int start, vector<vector<int>> &res)\n\t{\n\t\tres.push_back(stack);\n\t\tfor (int i = start; i < nums.size(); i++)\n\t\t{\n\t\t\tstack.push_back(nums[i]);\n\t\t\tdfs(nums, i + 1, res);\n\t\t\tstack.pop_back();\n\t\t}\n\t}\n};",
    "language": "cpp"
  },
  "node_id": "dailycode-6a239526fac34bcc9894cfee622ca3a4",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600469824"
}