Advertisement
SalmaYasser

Untitled

Dec 4th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class Solution {
  2. public:
  3.  
  4. void fun (vector <vector <int>> &res , vector <int> &path, vector <int> &nums, int idx)
  5. {
  6.  
  7. res.push_back (path);
  8.  
  9. for (int i = idx ; i < nums.size(); i++)
  10. {
  11. path.push_back(nums[i]);
  12. fun (res , path , nums , i + 1);
  13. path.pop_back();
  14.  
  15. }
  16. }
  17. vector<vector<int>> subsets(vector<int>& nums) {
  18. vector < vector <int> > res ;
  19. vector <int> path;
  20. fun (res , path, nums , 0);
  21.  
  22. return res;
  23. }
  24.  
  25. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement