My solution use C++ code


  • 1
    W
    class Solution {
    public:
        vector< vector<int> > generate(int numRows) {
        vector< vector<int> > answer;
        if (numRows==0)
        return answer;
        vector<int> result(1,1);
        answer.push_back(result);
        for (int i=1;i!=numRows;++i){
            result.insert(result.begin(),1);
            for (int j=1;j!=result.size()-1;++j){
                result[j]=result[j]+result[j+1];
            }
        answer.push_back(result);
        }
        return answer;
        }
    };

Log in to reply
 

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