O(k) space 6 lines C++


  • 0
    Y
    vector<int> getRow(int rowIndex) {
        vector<int> res;
        for (int i = 0; i <= rowIndex; i++){
            res.push_back(1);
            for (int j = i-1; j >= 1; j--) res[j] += res[j-1];
        }
        return res;
    }

Log in to reply
 

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