LeetCode 119. Pascal’s Triangle II
Solution1:我的答案
简单题目!!!OK!
class Solution {
public:
vector<int> getRow(int rowIndex) {
if (!rowIndex) return {1};
vector<int> res;
for (int i = 0; i <= rowIndex; i++) {
res.push_back(1);
for (int j = res.size() - 2; j >= 1; j--)
res[j] += res[j-1];
}
return res;
}
};