leetcode

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

3211.cpp (359B)


      1 class Solution {
      2   public:
      3     vector<string> validStrings(int n) {
      4         vector<string> res = {"0", "1"};
      5 
      6         for (int i = 1; i < n; i++) {
      7             for (int j = size(res) - 1; j >= 0; j--) {
      8                 if (res[j].back() == '1') res.push_back(res[j] + '0');
      9                 res[j] += '1';
     10             }
     11         }
     12 
     13         return res;
     14     }
     15 };