public class Solution {
public IList<IList<int>> Generate(int numRows) {
var list = new List<IList<int>>(); for (int i = ; i < numRows; i++)
{
var row = new List<int>();
if (i == )
{
row.Add();
}
else if (i == )
{
row.Add();
row.Add();
}
else
{
var prerow = list[i - ].ToList(); for (int j = ; j <= i; j++)
{
if (j == )
{
row.Add();
}
else if (j == i)
{
row.Add();
}
else
{
row.Add(prerow[j - ] + prerow[j]);
}
}
}
list.Add(row);
} return list;
}
}

https://leetcode.com/problems/pascals-triangle/#/description

leetcode118的更多相关文章

  1. 每天一道LeetCode--118. Pascal's Triangle(杨辉三角)

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

  2. [LeetCode118]Pascal's Triangle

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,R ...

  3. [Swift]LeetCode118. 杨辉三角 | Pascal's Triangle

    Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's t ...

  4. [leetcode-118]Pascal's triangle 杨辉三角

    Pascal's triangle (1过) Given numRows, generate the first numRows of Pascal's triangle. For example, ...

  5. LeetCode118.杨辉三角

    给定一个非负整数 numRows,生成杨辉三角的前 numRows 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例: 输入: 5 输出: [ [1], [1,1], [1,2,1], [ ...

  6. LeetCode118:Pascal&#39;s Triangle

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

  7. LeetCode118 杨辉三角 Python

    给定一个非负整数 numRows,生成杨辉三角的前 numRows 行. 示例:输入: 5 输出: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] cl ...

  8. LeetCode118. Pascal's Triangle 杨辉三角

    题目 给定行数,生成对应的杨辉三角 思考 同一行是对称的,最大的下标为(行数+1)/2;1,1,2,3,6;下标从0开始,则对应分别为0.0.1.1.2.2 对于第偶数行,个数也是偶数,对于奇数行,个 ...

  9. 2017-3-6 leetcode 118 169 189

    今天什么都没发生 ================================================= leetcode118 https://leetcode.com/problems ...

随机推荐

  1. 《DSP using MATLAB》Problem 3.18

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  2. bootstrap中如何控制input的宽度

    ☆1☆ bootstrap中如何控制input的宽度: v2版本:定义了很多class,可用在input. "input-block-level"."input-mini ...

  3. 关于jdbc的面试题

    什么是JDBC,在什么时候会用到它? JDBC的全称是Java DataBase Connection,也就是Java数据库连接,我们可以用它来操作关系型数据库.JDBC接口及相关类在java.sql ...

  4. About Apache Cordova

    Apache Cordova is a set of device APIs that allow a mobile app developer to access native device fun ...

  5. 【转】每天一个linux命令(50):crontab命令

    原文网址:http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html 前一天学习了 at 命令是针对仅运行一次的任务,循环运行的例行性计划 ...

  6. asm数据文件迁移(os–>asm)

    --添加测试表空间 SQL> create tablespace xff datafile '/u01/oradata/xifenfei.dbf' size 10m autoextend on ...

  7. Angular 4 路由介绍

    Angular 4 路由 1. 创建工程 ng new router --routing 2. 创建home和product组件 ng g component home ng g component ...

  8. Openwrt TTL线刷

    1.接通串口,网线: 2.打开串口软件SecureCRT: 3.按复位键,不断地出现信息: 4.2秒内按任意键停下来,出现uboot> 5.输入httpd 6.打开网页,输入ip 7.开始更新, ...

  9. 【python】class之类的定义

    使用class定义类,可以提供一个可选的父类或者基类,如果没有合适的基类,那就使用object作为基类,也可以不写.class FooClass (object)或者class FooClass: v ...

  10. MVC文件图片ajax上传轻量级解决方案,使用客户端JSAjaxFileUploader插件01-单文件上传

    前段时间做了几个关于图片.文件上传的Demo,使用客户端Query-File-Upload插件和服务端Badkload组件实现多文件异步上传,比如"MVC文件上传04-使用客户端jQuery ...