首页 > 其他 > 详细

119 Pascal's Triangle

时间:2015-05-29 07:27:35      阅读:153      评论:0      收藏:0      [点我收藏+]
public class Solution {
    public ArrayList<Integer> getRow(int rowIndex) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        if (rowIndex < 0) {
            return res;
        }
        
        res.add(1);
        for (int i = 1; i <= rowIndex; i++) {
            for (int j = res.size() - 2; j >= 0; j--) {
                res.set(j+1, res.get(j) + res.get(j + 1));
            }
            res.add(1);
        }
        return res;
    }
}

 

119 Pascal's Triangle

原文:http://www.cnblogs.com/77rousongpai/p/4537568.html

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