[LeetCode]Generate Parentheses

Beats 66.80% of cpp submissions.

class Solution {  
public:  
    vector<string> generateParenthesis(int n) {
        vs = vector<string>();
        generator("(", n-1, n);
        return vs;
    }

private:

    vector<string> vs;

    void generator(string s, int left, int right) {
        if(left == 0) {
            while(right--) {
                s += ")";
            }
            vs.push_back(s);
            return;
        }

        generator(s + "(", left-1, right);
        if(left < right) {
            generator(s + ")", left, right-1);
        }
    }
};