/*本题可参照Pascal’s Triangle的方法。只需在Pascal’s Triangle的
解题方法中,将保存整个杨辉三角,改为保存当前行即可。
方法参考自:https://github.com/soulmachine/leetcode*/
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> result;
if(rowIndex < 0) return result;
for(int i = 0; i <= rowIndex; ++i){
for(int j = i - 1; j > 0; --j){
result[j] = result[j-1] + result[j];
}
result.push_back(1);
}
return result;
}
};
09-23
09-23