-
Notifications
You must be signed in to change notification settings - Fork 0
119_Pascal'sTriangleII
a920604a edited this page Apr 14, 2023
·
1 revision
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> ret{1};
for(int i=1;i<=rowIndex ; ++i){
int pre = ret[0];
for(int j=1;j<i ; ++j){
int cur = ret[j];
ret[j] += pre;
pre = cur;
}
ret.push_back(1);
}
return ret;
}
};
- time complexity
O(n)
- space complexity
O(n)
footer