-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path118.cpp
More file actions
29 lines (27 loc) · 875 Bytes
/
Copy path118.cpp
File metadata and controls
29 lines (27 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*******************************************************************************
> File Name: 118.cpp
> Author: sillyplus
> Mail: oi_boy@sina.cn
> Created Time: Thu Mar 24 18:15:14 2016
*******************************************************************************/
class Solution {
public:
vector<vector<int>> generate(int numRows) {
vector<vector<int>> ret;
for (int i = 0; i < numRows; ++i) {
vector<int> tmp;
if (i == 0) {
tmp.push_back(1);
} else {
vector<int> pre = ret[i-1];
tmp.push_back(1);
for (int j = 1; j < pre.size(); ++j) {
tmp.push_back(pre[j] + pre[j-1]);
}
tmp.push_back(1);
}
ret.push_back(tmp);
}
return ret;
}
};