My 6 lines 0ms o(k) space C++ solution


  • 1
    A
    vector<int> getRow(int rowIndex) {
        vector<int> row(1, 1);
        while(rowIndex-- > 0) {
            row.push_back(0);
            for(int i = row.size() - 1; i > 0; i --) {
                row[i] += row[i-1];
            }
        }
        return row;
    }

Log in to reply
 

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