当前位置:网站首页>Leetcode Yanghui triangle
Leetcode Yanghui triangle
2022-06-12 21:56:00 【include12138】
My solution : Each number of the next layer is the sum of the upper left and upper right of the layer
class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> outter=new ArrayList<List<Integer>>();
if(numRows==0)
return outter;
ArrayList<Integer> inner = new ArrayList<Integer>();
inner.add(1);
outter.add(inner);
int outterIndex=0;
while(outter.size()!=numRows) {
ArrayList<Integer> lastLevel = (ArrayList<Integer>) outter.get(outterIndex);
ArrayList<Integer> tmp = new ArrayList<Integer>();
for(int i=0;i<lastLevel.size()+1;i++) {
int left=i>0?lastLevel.get(i-1):0;
int right=i<lastLevel.size()?lastLevel.get(i):0;
int res=left+right;
tmp.add(res);
}
outter.add(tmp);
outterIndex++;
}
return outter;
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
边栏推荐
- Semester summary of freshman year
- Ansible playbook and ansible roles (III)
- 大学期间零基础如何开展编程学习
- 【QNX Hypervisor 2.2 用户手册】4.2 支持的构建环境
- Use group_ Dplyr issues when using group_ by(multiple variables)
- PCB封装下载网站推荐及其详细使用方法
- SQL调优指南笔记13:Gathering Optimizer Statistics
- SQL tuning guide notes 15:controlling the use of optimizer statistics
- What is embedded
- SQL调优指南笔记18:Analyzing Statistics Using Optimizer Statistics Advisor
猜你喜欢

Ansible playbook和Ansible Roles(三)

Xingda easy control modbustcp to profibusdp

SQL调优指南笔记14:Managing Extended Statistics

You can move forward or backward. This function in idea is amazing!

SQL tuning guide notes 18:analyzing statistics using optimizer statistics Advisor

JVisualVM初步使用

Have you really learned the common ancestor problem recently?

KDD2022 | GraphMAE:自监督掩码图自编码器

SQL调优指南笔记8:Optimizer Access Paths
![[C language] data type occupation](/img/12/e0f9679076d89fb5bd993ee3c345bf.jpg)
[C language] data type occupation
随机推荐
SQL tuning guide notes 8:optimizer access paths
Oracle数据库中查询执行计划的权限
“Oracle数据库并行执行”技术白皮书读书笔记
脱颖而出!OceanBase 入选 2021“科创中国”开源创新榜单
经济学人聚焦WTO MC12:数字经济或成重要议题
Vagrantbox reinstalling the vboxsf driver
The ifeq, filter and strip of makefile are easy to use
Recommended Chinese font in the code input box of Oracle SQL developer
Oracle LiveLabs实验:Introduction to Oracle Spatial
Ansible playbook和变量(二)
MySQL体系结构及基础管理(二)
Oracle livelabs experiment: introduction to Oracle Spatial
利用ADG Standby克隆PDB
SQL tuning guide notes 17:importing and exporting optimizer statistics
同花顺能开户吗,在同花顺开户安全么,证券开户怎么开户流程
Xingda easy control modbustcp to profibusdp
Ansible playbook and ansible roles (III)
Ansible PlayBook et ansible roles (3)
Npoi create word
[QNX hypervisor 2.2 user manual] 4.4 build host