LeetCode 118. Pascal’s Triangle
Solution1:我的答案
简单题,一遍过!
class Solution {
public:
vector<vector<int>> generate(int numRows) {
if (!numRows) return {};
vector<vector<int> > res;
vector<int> temp = {1};
for (int i = 0; i < numRows; i++) {
res.push_back(temp);
temp.push_back(1);
for (int j = temp.size() - 2; j >= 1; j--)
temp[j] += temp[j - 1];
}
return res;
}
};
博客围绕LeetCode 118. Pascal’s Triangle展开,作者给出了自己的答案,认为这是一道简单题,且一次通过。
491

被折叠的 条评论
为什么被折叠?



