Here is my solution with O(K) space and 0ms 0.0


  • 0
    A
    vector<int> getRow(int rowIndex)
    {
        vector<int> vi(rowIndex + 1);
        vi[0] = vi[1] = 1;
        for(int row = 2; row <= rowIndex; row++) {
            for(int index = rowIndex / 2; index > 0; index--) {
                vi[row] = 1;
                vi[index] = vi[rowIndex - index] = vi[index] + vi[index-1];
            }
        }
        return vi;
    }
    

Log in to reply
 

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