class Solution {
public:
vector<int>getRow(int rowIndex) {
vector<int> v(rowIndex + 1);
v[0] = 1;
for(int i = 1;i < rowIndex + 1;i ++){
v[i] = 1;
for(int j = i - 1;j > 0;j --)
v[j] = v[j - 1] + v[j];
}
return v;
}
};
[LeetCode] Pascal's Triangle II
最新推荐文章于 2019-06-24 19:31:47 发布