Brief C++ method with public variables


  • 0
    G

    '''
    class Solution {
    public:
    vector<vector<int>> results;
    vector<int> palin;
    void travelsal(int k, int n, int j)
    { if(k < 0) return;
    if(k == 0 && n == 0)
    results.push_back(palin);
    for(int i = j ; i <= 9; i ++) {
    palin.push_back(i);
    travelsal(k - 1, n - i, i + 1);
    palin.pop_back();
    }
    }
    vector<vector<int>> combinationSum3(int k, int n) {
    travelsal(k, n, 1);
    return results;
    }
    };
    '''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.