首页 > 其他 > 详细

119. Pascal's Triangle II

时间:2018-05-18 17:08:02      阅读:161      评论:0      收藏:0      [点我收藏+]
 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     vector<int> getRow(int rowIndex) 
12     {
13         vector<int> res(rowIndex+1,0);
14         res[0]=1;
15         for(int i=1;i<rowIndex+1;i++)
16             for(int j=i;j>=1;j--)
17                 res[j]+=res[j-1];
18         return res;    
19     }
20 };

这个直接计算杨辉三角某一行的算法有点骚。

119. Pascal's Triangle II

原文:https://www.cnblogs.com/zhuangbijingdeboke/p/9056964.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!