119. Pascal's Triangle II

来源:互联网 发布:怎么发淘宝优惠券赚钱 编辑:程序博客网 时间:2024/05/21 02:48
class Solution {public:    vector<int> getRow(int rowIndex) {        if(rowIndex==0) return {1};        vector<int> temp(1,1);        for(int i=2;i<=rowIndex+1;i++)        {            vector<int> temp1(temp);            for(int j=1;j<i-1;j++)            {                temp[j]=temp1[j-1]+temp1[j];            }            temp.push_back(1);        }        return temp;    }};
0 0
原创粉丝点击