My C++ 0ms code


  • 1
    M
    class Solution {
    public:
        vector<vector<int>> generate(int numRows) {
            vector<vector<int>> res;
            vector<int> temp;
            for (int i = 1; i <= numRows; i++) {
                for (int j = i - 1; j >= 2; j--) {
                    temp[j - 1] += temp[j - 2];
                }
                temp.push_back(1);
                res.push_back(temp);
            }
            return res;
        }
    };

Log in to reply
 

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