Created
January 22, 2019 04:53
-
-
Save kanrourou/9dbaf9ad5737c6f20f184a1e6140241a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
vector<vector<int>> subsets(vector<int>& nums) { | |
vector<vector<int>> res; | |
vector<int> curr; | |
dfs(nums, 0, curr, res); | |
return res; | |
} | |
private: | |
void dfs(vector<int>& nums, int start, vector<int>& curr, vector<vector<int>>& res) | |
{ | |
res.push_back(curr); | |
for(int i = start; i < nums.size(); ++i) | |
{ | |
curr.push_back(nums[i]); | |
dfs(nums, i + 1, curr, res); | |
curr.pop_back(); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment