码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode - Refresh - Pascal's Triangle II

时间:2015-03-21 18:37:00      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

Exact same as I.

 1 class Solution {
 2 public:
 3     vector<int> getRow(int rowIndex) {
 4         if (rowIndex < 0) return vector<int> ();
 5         vector<int> result(1, 1);
 6         for (int i = 1; i <= rowIndex; i++) {
 7             for (int j = result.size()-1; j > 0; j--) {
 8                 result[j] += result[j-1];
 9             }
10             result.push_back(1);
11         }
12         return result;
13     }
14 };

 

LeetCode - Refresh - Pascal's Triangle II

标签:

原文地址:http://www.cnblogs.com/shuashuashua/p/4355881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!