Pascal's Triangle II

class Solution {
public:
    vector<int> getRow(int rowIndex) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        vector<int> result;
        if(rowIndex<0)
        return result;
        vector<int> temp;
        temp.push_back(1);
        result = temp;
        for(int i = 1;i<=rowIndex;i++)
        {
            temp.clear();
            temp.push_back(1);
            for(int j = 1;j<i;j++)
            {
                temp.push_back(result[j-1]+result[j]);
            }
            temp.push_back(1);
            result = temp;
        }
        return result;
    }
};
原文地址:https://www.cnblogs.com/727713-chuan/p/3312285.html