2ms short C++ Solution


  • 4
    X
    class Solution {
    public:
        vector<int> getRow(int rowIndex) {
            vector<int> result(1,1);
            for(int i=1; i<=rowIndex; i++) {
                result.push_back(1);
                for(int j=result.size()-2; j>0; j--)
                    result[j] += result[j-1];
            }
            return result;
        }
    };

Log in to reply
 

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