1
class Solution {
2
public:
3
vector<vector<int>> generate(int numRows) {
4
vector<vector<int>> ans(numRows, vector<int>());
5
for (int i = 0; i < numRows; i++) {
6
for (int j = 0; j <= i; j++) {
7
if (j == 0 || j == i) {
8
ans[i].push_back(1);
9
} else {
10
ans[i].push_back(ans[i - 1][j - 1] + ans[i - 1][j]);
11
}
12
}
13
}
14
return ans;
15
}
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0