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 ...
随机推荐
- 使用Bootstrap插件datapicker获取时间
引入css和js <link rel="stylesheet" href="/${appName}/commons/css/datapicker/datepicke ...
- python 字符串、列表、字典相关内建方法
"""字符串相关内建方法""" # a = ["qwe", "name", "sex&qu ...
- 本地Run Page时报检测到意外的 URL 参数,它将被忽略。
经查,是因为我RUN的时候 Target URL -- http://MY-PC:8988/OA_HTML/runregion.jsp 将MY-PC更改为本地IP即可. 设置方法 Tools - Em ...
- 使用Bus.js进行兄弟(非父子)组件通信
首先需要在任意地方添加一个bus.js: 在bus.js里面 写入下面信息 import Vue from 'vue' export default new Vue; 在需要通信的组件都引入Bus.j ...
- SpringMvc中@ModelAttribute注解的使用
一.绑定请求参数到指定对象 public String test1(@ModelAttribute("user") UserModel user) 只是此处多了一个注解@Model ...
- HDU 2612 Find a way bfs 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=2612 bfs两次就可将两个人到达所有kfc的时间求出,取两人时间之和最短的即可,这个有点不符合实情,题目应该出两 ...
- DOM之一些小实验demo
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- Struts2自定义标签3模仿原有的s:if s:elseif s:else自定义自己的if elsif else
第一步:webroot/web-inf下简历str.tld文件 <?xml version="1.0" encoding="UTF-8"?> < ...
- 在IE7+ 中弹出窗口并关闭本身窗口的脚本(备忘)
window.onload =function(){ window.open("http://www.126.com"); window.opener=null; window.o ...
- centos7下Firewall使用详解
安装它,只需 # yum install firewalld如果需要图形界面的话,则再安装# yum install firewall-config 一.介绍 防火墙守护 firewalld 服务引入 ...