C++ 0ms solution


  • 0
    Z
    class Solution {
    public:
    vector<int> getRow(int rowIndex) {
        vector<int> v;
        if(rowIndex < 0) return v;
        v.push_back(1);
        if(!rowIndex) return v;
        while(rowIndex--){
            v.push_back(0);
            for(int i = v.size() - 1; i > 0; i--)
                v[i] += v[i-1];
        }
        return v;
    }
    };

Log in to reply
 

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