leetcode119
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的更多相关文章
- 每天一道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, ...
- [LeetCode119]Pascal's Triangle II
题目: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [ ...
- [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 ...
- LeetCode119.杨辉三角II
给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例: 输入: 3 输出: [1,3,3,1] 进阶: 你可以优化你的算法到 O ...
- LeetCode119.杨辉三角 II
119.杨辉三角 II 描述 给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行. 在杨辉三角中,每个数是它左上方和右上方的数的和. 示例 输入: 3 输出: [1,3,3,1] 进阶 ...
- LeetCode119. Pascal's Triangle II
Description Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, ...
- 2017-3-7 leetcode 66 119 121
今天纠结了一整天============================================================== leetcode66 https://leetcode.c ...
随机推荐
- JavaScript学习总结(二十一)——使用JavaScript的数组实现数据结构中的队列与堆栈
今天在项目中要使用JavaScript实现数据结构中的队列和堆栈,这里做一下总结. 一.队列和堆栈的简单介绍 1.1.队列的基本概念 队列:是一种支持先进先出(FIFO)的集合,即先被插入的数据,先被 ...
- PHP:第五章——字符串输出函数
<?php header("Content-Type:text/html;charset=utf-8"); /*字符串输出函数*/ //1.echo 输出一个或多个字符 // ...
- 彻底弄懂jQuery事件原理二
上一篇说到,我们在最外层API的on,off,tiggler,triggerHandler调用的是event方法的add,remove和tirgger方法,本篇就来介绍event辅助类 \ 先放个图, ...
- L175 Endorestiform Nucleus: Scientist Just Discovered a New Part of the Human Brain
The newly named Endorestiform Nucleus sits in the inferior cerebellar小脑 peduncle, at the junction be ...
- PostgreSQL常用插件收集
hexdump -C 数据表文件 -- 查看表文件中数据. pg_stat_statements pgcompacttable -- 在减少锁的情况下,清理表和索引的老空间. pg_repack--P ...
- Nginx 反向代理 如何在web应用中获取用户ip
转载:http://blog.csdn.net/bao19901210/article/details/52537279 问题背景: 在实际应用中,我们可能需要获取用户的ip地址,比如做异地登陆的判断 ...
- Ethereum部署私有合约常见问题汇总
常见问题 问题1 问题描述: callback contain no result Error: authentication needed: password or unlock 这里的问题是当前所 ...
- BZOJ4571: [Scoi2016]美味【主席树】【贪心】
Description 一家餐厅有 n 道菜,编号 1...n ,大家对第 i 道菜的评价值为 ai(1≤i≤n).有 m 位顾客,第 i 位顾客的期 望值为 bi,而他的偏好值为 xi .因此,第 ...
- 安装配置adb工具及遇到的问题
一. 下载安装 配置环境 二.遇到的问题 1.Terminal 不是内部或外部命令,也不是可运行程序或批处理文件 https://blog.csdn.net/wuqilianga/article/de ...
- angularJS指令动态加载template
angularJS提供了自定义指令的功能,指令可以定义自己的模板控制器,这个就类似于现在框架的组件,一个指令一般对应一个模板, templateUrl: 'templates/exportTmp.ht ...