当前位置:网站首页>2022.5.26-----leetcode.699
2022.5.26-----leetcode.699
2022-06-09 12:28:00 【路Lu727】
//只能用普遍法。。。
public List<Integer> fallingSquares(int[][] positions) {
int n = positions.length;
List<Integer> heights = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
int left1 = positions[i][0], right1 = positions[i][0] + positions[i][1] - 1;
int height = positions[i][1];
for (int j = 0; j < i; j++) {
int left2 = positions[j][0], right2 = positions[j][0] + positions[j][1] - 1;
if (right1 >= left2 && right2 >= left1) {
height = Math.max(height, heights.get(j) + positions[i][1]);
}
}
heights.add(height);
}
for (int i = 1; i < n; i++) {
heights.set(i, Math.max(heights.get(i), heights.get(i - 1)));
}
return heights;
}
边栏推荐
- Detailed explanation of three value transfer methods between wechat applet pages
- Yunna | what does database monitoring generally monitor
- Hype plagiarism, insider fraud common NFT scams and security suggestions on opensea
- [NOIP2015 提高组] 运输计划
- C language linear list -- static linked list
- 机器学习-学习笔记(二) --&gt; 模型评估与选择
- 论文阅读《LEAStereo:Hierarchical Neural Architecture Search for Deep Stereo Matching》
- com.alibaba.fastjson.JSONException: syntax error, pos 1, line 1, column 2测试
- 云呐|数据库监控一般监控什么
- Digital transformation: how to gain organizational recognition?
猜你喜欢
![[C language practice - printing square and its deformation]](/img/20/51a3f5d104275026605db268b64607.png)
[C language practice - printing square and its deformation]

手把手教你用js实现一个虚拟机

炒作剽窃、内鬼欺诈 OpenSea上常见的NFT骗局及安全建议

Notes - round square tree

【C语言练习——合并两个有序序列】

Yunna | how to manage the physical assets of the company

jstat 详解

Yunna | how to do a good inventory of fixed assets? How to count fixed assets

网络空间测绘国内外发展及现状

精益产品开发体系最佳实践及原则
随机推荐
【C语言练习——打印菱形及其变形】
C language -- single cycle linked list
手把手教你用js实现一个虚拟机
Arm architecture corresponding to commonly used chips in the market
云呐|固定资产归哪个部门管理,归谁管理
What are the types and aspects of Yunna asset management system
[leetcode weekly race record] record of the 294th weekly race
Yunna | which department manages the fixed assets and who manages them
com. alibaba. fastjson. Jsonexception: syntax error, POS 1, line 1, column 2 test
Database day-2
面试题 08.01. 三步问题
面试题 08.04. 幂集
云呐|智能运维管理系统平台,可视化运维系统管理
精益产品开发体系最佳实践及原则
Yunna | how to do a good inventory of fixed assets? How to count fixed assets
Record the troubleshooting of high program memory consumption
U8g2图形库与STM32移植(I2C,软件与硬件)
云呐|行政单位固定资产管理制度,单位固定资产管理办法
数字化转型:如何获得组织的认可?
wsl2环境搭建