leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0078.cpp (363B)


      1 class Solution {
      2   public:
      3     vector<vector<int>> subsets(vector<int> &nums) {
      4         vector<vector<int>> res;
      5 
      6         res.push_back({});
      7         for (int num : nums) {
      8             for (int i = res.size() - 1; i >= 0; i--) {
      9                 res.push_back(res[i]);
     10                 res.back().push_back(num);
     11             }
     12         }
     13         return res;
     14     }
     15 };