文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
Pascal's Triangle2. Solution
class Solution {
public:
vector<vector<int>> generate(int numRows) {
vector<vector<int>> result;
for(int i = 0; i < numRows; i++) {
vector<int> nums(i + 1, 1);
result.push_back(nums);
for(int j = 1; j < i; j++) {
result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
}
}
return result;
}
};
网友评论