Leetcode 109

时间:2023-03-10 01:14:03
Leetcode 109
//这种也是空间复杂度为O(K)的解法,就是边界有点难写
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> res;
res.push_back();
if(rowIndex == ) return res;
res.push_back();
if(rowIndex == ) return res;
for(int i=;i <= rowIndex;i++){
res.push_back();
int a = res[];
int b = res[];
for(int j=;j < i;j++){
res[j] = a+b;
a = b;
b = res[j+];
}
res[i] = ;
}
return res;
}
};