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

[LeetCode] Pascal's Triangle II

时间:2014-09-10 21:02:51      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   ar   for   div   sp   log   

 1 public class Solution {
 2     public List<Integer> getRow(int rowIndex) {
 3         List<Integer> result = new ArrayList<Integer>();
 4         for (int i=0; i<=rowIndex; i++) {
 5             for (int j=i; j>=0; j--) {
 6                 if (j==i) result.add(1);
 7                 else if (j>0) result.set(j, result.get(j) + result.get(j-1));
 8             }
 9         }
10         return result;
11     }
12 }

 

[LeetCode] Pascal's Triangle II

标签:style   blog   color   io   ar   for   div   sp   log   

原文地址:http://www.cnblogs.com/yuhaos/p/3965060.html

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