#include using namespace std; class Solution { public: vector> subsets(vector &nums) { vector> res; dfs(nums, 0, res); return res; } private: vector stack; void dfs(vector &nums, int start, vector> &res) { res.push_back(stack); for (int i = start; i < nums.size(); i++) { stack.push_back(nums[i]); dfs(nums, i + 1, res); stack.pop_back(); } } };