Skip to content

Commit fe57a2d

Browse files
author
cpppy
authored
Create 119_Pascal's_Triangle_II.cc
1 parent a9e1d9f commit fe57a2d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

119_Pascal's_Triangle_II.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution {
2+
public:
3+
vector<int> getRow(int rowIndex) {
4+
vector<int> a;
5+
vector<int> b;
6+
a.push_back(1);
7+
if(rowIndex==0) return a;
8+
b.push_back(1);
9+
b.push_back(1);
10+
a.clear();
11+
a=b;
12+
for(int i=2;i<=rowIndex;++i){
13+
for(int j=1;j<i;++j){
14+
b[j]=a[j-1]+a[j];
15+
}
16+
b.push_back(1);
17+
a.clear();
18+
a=b;
19+
}
20+
return b;
21+
22+
}
23+
};

0 commit comments

Comments
 (0)