leetcode218
from heapq import * class Solution:
def getSkyline(self, LRH):
skyline = []
i, n = 0, len(LRH)
liveHR = []
while i < n or liveHR:
if not liveHR or i < n and LRH[i][0] <= -liveHR[0][1]:
x = LRH[i][0]
while i < n and LRH[i][0] == x:
heappush(liveHR, (-LRH[i][2], -LRH[i][1]))
i += 1
else:
x = -liveHR[0][1]
while liveHR and -liveHR[0][1] <= x:
heappop(liveHR)
height = len(liveHR) and -liveHR[0][0]
if not skyline or height != skyline[-1][1]:
skyline += [x, height],
return skyline
神题神解,
参考1:https://leetcode.com/problems/the-skyline-problem/discuss/61194/108-ms-17-lines-body-explained
参考2:https://briangordon.github.io/2014/08/the-skyline-problem.html
leetcode218的更多相关文章
- [Swift]LeetCode218. 天际线问题 | The Skyline Problem
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- LeetCode218. The Skyline Problem
https://leetcode.com/problems/the-skyline-problem/description/ A city's skyline is the outer contour ...
- leetcode218 天际线问题
来自leetcode题解:扫描线法AlgsCG class Solution { public: vector<vector<int>> getSkyline(vector&l ...
- leetcode 日常清单
a:excellent几乎一次ac或只有点小bug很快解决:半年后再重刷: b:经过艰难的debug和磕磕绊绊或者看了小提示才刷出来: c:经过艰难的debug没做出来,看答案刷的: 艾宾浩斯遗忘曲线 ...
随机推荐
- C#创建自定义Object对象
, B=,J=}; 记录一下,老写成 var obj = new object() { O=0, B=0,J=0};
- OpenSSH多路复用Multiplexing配置
设置 Session Multiplexing 在客户端节点如下配置/etc/ssh/ssh_config 或~/.ssh/config 就可以直接开启 Session Multiplexing 功能 ...
- 学习笔记之深度学习(Deep Learning)
深度学习 - 维基百科,自由的百科全书 https://zh.wikipedia.org/wiki/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0 深度学习(deep lea ...
- dubbo项目部署遇到的问题
部署的项目结构如下: [图片] 1 Socket >>>相关的报错 检查下zookeeper的服务端cmd和客户端cmd是否起来了 2 jdbc.DataSourceProperti ...
- 1126 Eulerian Path (25 分)
1126 Eulerian Path (25 分) In graph theory, an Eulerian path is a path in a graph which visits every ...
- Kowala协议:一组分布式,自我调节,资产跟踪特性的加密货币(二)
对于稳定币来言,设计过程中会遇到很多细节的问题,今天来讲述下有关通证设计过程中的一些问题. 1.计算手续费 计算费是交易费的一部分,转移给kUSD矿工,并由以下公式决定: 其gasUsed(t) 是用 ...
- [UE4]统一颜色
这里说的统一颜色,说的是每个玩家看到另外的一个玩家的颜色都是一致的,而不是同一个队伍相同的颜色. 一.同样的在ShooterPlayerState中添加一个变量Color(队伍颜色),设置为可复制. ...
- [UE4]控件模板参数
创建的时候就会变成这样了.
- [UE4]在蓝图中设置图片
- log4j自带的两个类MDC和NDC作用以及用途
原文转载至: https://blog.csdn.net/joeyon/article/details/52982330 要想实现获取IP并显示在log中必须先了解log4j自带的两个类MDC和NDC ...