class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> value(rowIndex+1,0);
value[0]=1;
for(int i=0;i<rowIndex;++i)
{
for(int j=rowIndex;j>=1;--j)//倒着循环可以节省空间,避免再设一个容器了。
{
value[j]+=value[j-1];
}
}
return value;
}
};
Leetcode 119c++
最新推荐文章于 2021-12-27 11:16:57 发布