C++_O(k)_Accepted


  • 0

    Basic idea is replacing.

    class Solution {
    public:
    vector<int> getRow(int rowIndex) {
        vector<int> res(rowIndex + 1,0);
        int end = 0;
        res[0] = 1;
        for(int i = 1; i <= rowIndex; ++i){
            res[end + 1] = 1;
            while(end > 0){
                res[end] += res[end-1];
                end--;
            }
            end = i;
        }
        return res;
    }
    };

Log in to reply
 

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