LeetCode 119. Pascal's Triangle II
程序员文章站
2022-04-01 12:01:12
...
Problem
Notes
与118题一样,也是杨辉三角的题,只不过只需要输出杨辉三角的第k层。
Codes
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> pre;
for(int i=0;i<=rowIndex;++i)
{
vector<int> temp;
for(int j=0;j<=i;++j)
{
if(j==0||j==i)
temp.push_back(1);
else
temp.push_back(pre[j]+pre[j-1]);
}
pre=temp;
}
return pre;
}
};
Results
推荐阅读
-
Leetcode No.119 Pascal's Triangle II(c++实现)
-
杨辉三角(pascal's triangle)
-
LeetCode-119. Pascal's Triangle II
-
119. Pascal's Triangle II [杨辉三角形2]
-
119. Pascal's Triangle II
-
leetcode -- 119. Pascal's Triangle II
-
2018.05.03 leetcode #119. Pascal's Triangle II
-
【leetcode】119. Pascal's Triangle II
-
LeetCode 119. Pascal's Triangle II
-
[LeetCode]119. Pascal's Triangle II