生成Pascal triangle

package k;import java.util.ArrayList;
import java.util.List;public class PascalTriangle {/*** @param args*/public List<List<Integer>> generate(int numRows) {List<List<Integer>> resList = new ArrayList<List<Integer>>() ;if(numRows<=0)return resList;List<Integer> pre = new ArrayList<Integer>();pre.add(1);resList.add(pre);for(int i = 2;i<=numRows;i++){List<Integer> cur = new ArrayList<Integer>();cur.add(1);for(int j=0;j<pre.size()-1;j++)  {  cur.add(pre.get(j)+pre.get(j+1));  }  cur.add(1);  resList.add(cur);  pre = cur;  }  return resList;  }public static void main(String[] args) {// TODO Auto-generated method stub}}

Pascal trangle leetcode相关推荐

  1. LeetCode - Pascal's Trangle

    这道题是生成杨辉三角,看了下杨辉三角的性质,就可以解决了. 下面是AC代码: 1 /** 2 * Given numRows, generate the first numRows of Pascal ...

  2. LeetCode——Pascal#39;s Triangle

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Retu ...

  3. [LeetCode]119.Pascal#39;s Triangle II

    题目 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [ ...

  4. LeetCode - Easy - 119. Pascal‘s Triangle II

    Topic Array Description https://leetcode.com/problems/pascals-triangle-ii/ Given an integer rowIndex ...

  5. LeetCode - Easy - 118. Pascal‘s Triangle

    Topic Array Description https://leetcode.com/problems/pascals-triangle/ Given a non-negative integer ...

  6. [LeetCode]119.Pascal's Triangle II

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/SunnyYoona/article/details/43562603 题目 Given an ind ...

  7. leetcode python3 简单题119. Pascal's Triangle II

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百一十九题 (1)题目 英文: Given a non-negative ind ...

  8. leetcode python3 简单题118. Pascal's Triangle

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百一十八题 (1)题目 英文: Given a non-negative int ...

  9. LeetCode 118 Pascal's Triangle(帕斯卡三角形)(vector)

    翻译 给定一个行数字,生成它的帕斯卡三角形.例如,给定numRows = 5, 返回: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1] ] 原文 Given numR ...

最新文章

  1. JavaScript入门篇 - DOM操作
  2. Appium+python自动化19-iOS模拟器(iOS Simulator)安装自家APP
  3. python0.1+0.2_为什么0.1+0.2=0.30000000000000004
  4. windows上报错:Could not find a version that satisfies the requirement torch==0.4.1
  5. 1.什么是数据化运营——《数据挖掘与数据化运营实战》
  6. linux shell的二级菜单,linux shell编程之菜单选择(一)
  7. javascript(js)获取访客通过搜索引擎进入页面的搜索关键词的简洁有效代码
  8. jzoj6343-[NOIP2019模拟2019.9.7]Medium Counting【记忆化dfs,dp】
  9. 【OpenCV 例程200篇】04. 用 matplotlib 显示图像(plt.imshow)
  10. 行为设计模式 - Memento设计模式
  11. 开源 | 高颜值神经网络可视化工具
  12. 微信 app---uwp
  13. 常用的银行卡验证API接口——银行卡三元素API接口
  14. 论文详读《基于改进 LeNet-5 模型的手写体中文识别》
  15. 目标检测中的常见指标
  16. 水生植物拉丁文及缩写
  17. 易语言 vb c 那个写的程序运行快,VB好还是易语言
  18. 感恩中国30年,速速来看甲骨文数据库云大会
  19. ACP敏捷知识点汇总
  20. php人民币小写转大写函数

热门文章

  1. 男は失恋夜盗11台奔スポーツカーエンブレム腹いせ(写真)
  2. 30分钟学会js新特性
  3. UG NX 10 重新附着草图
  4. APP跟网址最常见的攻击和防守
  5. Android MediaPlayer控制进度播放音频
  6. 第 11 章 基于小波技术进行图像融合--MATLAB人工智能深度学习模块
  7. 基于kinect + EmguCV 的监控小应用(视频录制保存)
  8. 迅为《i.MX8MM开发板使用手册1.4版》大更新
  9. python显示等待隐式等待
  10. 细节6:算术右移和逻辑右移