class Solution {
public:
vector<int> getRow(int rowIndex) {
int k = rowIndex+1;
vector<int> result(k,0);
result[0] = 1;
int temp;
for(int i=2;i<=k;++i){
temp = result[0];
for(int j=1;j<i;++j){
result[j] += temp;
temp = result[j] - temp;
}
}
return result;
}
};
Pascal's Triangle II
最新推荐文章于 2022-02-07 21:31:57 发布