public class Solution {
public IList<int> GetRow(int rowIndex) {
List<List<int>> list = new List<List<int>>();
for (int i = ; i <= rowIndex; i++)
{
var row = new List<int>();
if (i == )
{
row.Add();
}
else if (i == )
{
row.Add();
row.Add();
}
else//i>=3
{
for (int j = ; j <= i; j++)
{
if (j == )
{
row.Add();
}
else if (j == i)
{
row.Add();
}
else
{
var pre = list[i - ];
row.Add(pre[j - ] + pre[j]);
}
}
}
list.Add(row);
}
var result = list.LastOrDefault();
return result;
}
}

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

leetcode119的更多相关文章

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

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

  2. [LeetCode119]Pascal's Triangle II

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

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

    Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note t ...

  4. LeetCode119.杨辉三角II

    给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例: 输入: 3 输出: [1,3,3,1] 进阶: 你可以优化你的算法到 O ...

  5. LeetCode119.杨辉三角 II

    119.杨辉三角 II 描述 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例 输入: 3 输出: [1,3,3,1] 进阶 ...

  6. LeetCode119. Pascal's Triangle II

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

  7. 2017-3-7 leetcode 66 119 121

    今天纠结了一整天============================================================== leetcode66 https://leetcode.c ...

随机推荐

  1. js做小数运算精度问题

    当js做小数运算时存在bug,大概是因为二进制和十进制转换之间的关系. bug如图 解决方案 1.运算结果后,乘以100再除以100.网上推荐这种方法但是乘以1000再除以1000依然存在精度问题 2 ...

  2. Educational Codeforces Round 23C

    超级坑的水题!!!想了两天没一点思路,看了题解第一段话就做出来了 刚开始一直在想找到通项就是例如an*10^n+...+a0*10^0-an-...-a0>=s,然后从这个里面找到规律,结果走进 ...

  3. 谈谈oracle里的join、left join、right join

    create table l as select 'left_1' as str,'1' as v from dual union allselect 'left_2' ,'2' as v from ...

  4. 微任务、宏任务与Event-Loop

    首先,JavaScript是一个单线程的脚本语言.所以就是说在一行代码执行的过程中,必然不会存在同时执行的另一行代码,就像使用alert()以后进行疯狂console.log,如果没有关闭弹框,控制台 ...

  5. @Column实体类中的使用(二十三)

  6. openfalcon源码分析之Judge

    openfalcon源码分析之Judge 本节内容 Judge功能 源码分析 设计优缺点 1. Judge功能 在open-falcon中,Judge模块的功能是通过从HBS上同步告警的strateg ...

  7. 一个简单的观察者模式的JS实现

    这不是原创文章,主要是写给自己看的.原文比较详细容易让人,我提取最简单最好理解的部分,便于我以后用到.参考http://www.cnblogs.com/TomXu/archive/2012/03/02 ...

  8. VUE的使用方法

    vueInit: function() { var _this = this; this.vue = new Vue({ el: '#pa', data: { //存放初始化数据 sourceData ...

  9. 自定义redis session

    1.思路 2.程序实现 1.用户系统类 这里模拟一个蹩脚的用户系统类(userSystem),如下: #coding=utf-8 #Redis实现用户系统 __author__ = 'beginman ...

  10. Libusb学习

    1.参考:http://www.cnblogs.com/Daniel-G/archive/2013/04/22/3036730.html https://baike.so.com/doc/506541 ...