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 ...
随机推荐
- Linux编写一个C程序HelloWorld
环境 需要文本编辑器和编译器,文本编辑器用linux(我用的centos7)自带的vi,编译器用gcc(GNU C Compiler/GNU Compiler Collection) 安装gcc,查看 ...
- Android下移植tcpflow
tcpflow是linux平台下的开源抓包工具,它能监听网络url,获取http请求的各种数据.tcpflow可以说是tcpdump的简约版.要想将tcpflow移植到Android平台中,就需要通过 ...
- ExtJS 6 如何引入Dashboard模版
最近很多人问我在ext js 6+的版本中怎么引入官方的dashboard模版,正好我好久没写博客了,这里我写一篇博客来说明一下. 在这里以ext js 6.2.1版本为例(注:需要安装Sencha ...
- spring boot 之热部署
热部署:当发现程序修改时自动启动应用程序. spring boot使用的是spring-boot-devtools是一个为开发者服务的一个模块.其原理用了classLoader 其中一个加载不变的类, ...
- Delphi 简体 繁体 转换
http://delphi.ktop.com.tw/board.php?cid=30&fid=69&tid=104986 試看看 這個是豬寶寶從網路上抄來的 檢視純文字版列印? fun ...
- Linux:提示符PS1个性设置
提示符PS1个性设置 1)默认PS1 echo $PS1 2)个性PS1 #去掉了默认显示的[]号#\e[1;34m\]\u:user名高亮显示并显示颜色#\e[5;33m\]\h:hostname主 ...
- Yii 入门
跳转到不同module Redirect to module after login Yii $this->redirect( array('/tradesman/default/index') ...
- iOS-----使用AddressBook管理联系人
使用AddressBook管理联系人 iPhone手机通常都是自带的Contacts应用,包括所有联系人的性(last name).名(first name).电话.E-mail地址.住址.生日等各种 ...
- 未能加载文件或程序集“NPOI”或它的某一个依赖项
自己遇到过得一个很麻瓜很耽误时间的bug,也请教了一些大神嫩是没找到解决方法 下面分享下问题和解决方法 做的是一个下载功能,本地是没问题IIS站点导出EXCEL的时候出错 我这边看不到错误信息,只能一 ...
- bootstrap table教程--后台数据绑定、特殊列处理、排序
上一篇文章介绍了基本的使用教程.本节主要介绍Bootstrap的后台数据绑定.特殊列处理及列的排序功能 1.数据绑定 一般做程序设计,很少是使用json文件直接绑定数据.基本上我们都是使用编程语言进行 ...