题目地址:


注意:做这道题前建议先做这道题Rectangle Area II - LeetCode
看这篇博客:LeetCode 850. Rectangle Area II


A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a program to output the skyline formed by these buildings collectively (Figure B).

Buildings Skyline Contour
The geometric information of each building is represented by a triplet of integers [Li, Ri, Hi], where Li and Ri are the x coordinates of the left and right edge of the ith building, respectively, and Hi is its height. It is guaranteed that 0 ≤ Li, Ri ≤ INT_MAX, 0 < Hi ≤ INT_MAX, and Ri - Li > 0. You may assume all buildings are perfect rectangles grounded on an absolutely flat surface at height 0.

For instance, the dimensions of all buildings in Figure A are recorded as: [ [2 9 10], [3 7 15], [5 12 12], [15 20 10], [19 24 8] ] .

The output is a list of “key points” (red dots in Figure B) in the format of [ [x1,y1], [x2, y2], [x3, y3], … ] that uniquely defines a skyline. A key point is the left endpoint of a horizontal line segment. Note that the last key point, where the rightmost building ends, is merely used to mark the termination of the skyline, and always has zero height. Also, the ground in between any two adjacent buildings should be considered part of the skyline contour.

For instance, the skyline in Figure B should be represented as:[ [2 10], [3 15], [7 12], [12 0], [15 10], [20 8], [24, 0] ].

Notes:

  • The number of buildings in any input list is guaranteed to be in the range [0, 10000].
  • The input list is already sorted in ascending order by the left x position Li.
  • The output list must be sorted by the x position.
  • There must be no consecutive horizontal lines of equal height in the output skyline. For instance, […[2 3], [4 5], [7 5], [11 5], [12 7]…] is not acceptable; the three lines of height 5 should be merged into one in the final output as such: […[2 3], [4 5], [12 7], …]

这道题目的意思是找天际线,并返回线段的左边的端点

LeetCode 218. The Skyline Problem相关推荐

  1. leetcode 218. The Skyline Problem | 218. 天际线问题(线段树)

    题目 https://leetcode-cn.com/problems/the-skyline-problem/ 题解 线段树问题,根据左神的思路改编,外加我想到的压缩的 tricks(数字范围太大, ...

  2. LeetCode——218. 天际线问题(The Skyline Problem)[困难]——分析及代码(Java)

    LeetCode--218. 天际线问题[The Skyline Problem][困难]--分析及代码[Java] 一.题目 二.分析及代码 1. 扫描线 + 优先队列 (1)思路 (2)代码 (3 ...

  3. [LeetCode-JAVA] The Skyline Problem

    题目:题目太长了,见链接-- > The Skyline Problem Notes: The number of buildings in any input list is guarante ...

  4. Leetcode:The Skyline Problem

    题目大意:太复杂了,不太想翻译.对于一丛相互交错的方形建筑,可以由一个二维数组表示各自的轮廓.求从远处观望时看到的天际线.所谓的天际线就是某一段水平区域上的等高线,其下方或者是建筑,或者是地面.求从左 ...

  5. [Swift]LeetCode218. 天际线问题 | The Skyline Problem

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...

  6. Java实现 LeetCode 218 天际线问题

    218. 天际线问题 城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓.现在,假设您获得了城市风光照片(图A)上显示的所有建筑物的位置和高度,请编写一个程序以输出由这些建筑物形成的天际线 ...

  7. LeetCode 218. 天际线问题(multiset优先队列)*

    文章目录 1. 题目 2. 解题 1. 题目 城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓. 现在,假设您获得了城市风光照片(图A)上显示的所有建筑物的位置和高度,请编写一个程序以输 ...

  8. LeetCode 218. 天际线问题(C++)*

    思路:优先队列+遍历 1.对于左端点:左端点且高度最高的那个就是左边缘: 2.对于右端点:首先右端点不可能是右边界;如果被删除的右端点是最高的,只有删除最高右端点后,该横坐标处的最高点才会是右边界: ...

  9. LeetCode Water and Jug Problem(巧妙转换为gcd问题)

    题意:给出x,y升水壶,问是否可以量出z升水.有三种操作:填满水壶,清空水壶. 从其中一个水壶倒入另一个水壶 代码如下: public class Solution {private int gcd( ...

最新文章

  1. c语言实现memcpy
  2. CynosDB技术详解——存储集群管理【文末有福利】
  3. 查看用户账户过期信息
  4. MATLAB利用串口接收数据,并实时显示图形
  5. python 下标 遍历列表_python中的数据结构与算法(1):列表、元组与字符串
  6. js遍历对象的key和value
  7. 营救(洛谷-P1396)
  8. 16年毕业,刚入行软件测试,就拿到这么多薪资......因为稳定的时刻学习
  9. Thread调用SaveFileDialog
  10. try-catch(C# 参考)
  11. C#+Winform用ReportViewer控件制作报表
  12. 层次分析法(AHP)——算数平均值法、几何平均值法、特征值法(Python实现,超详细注释)
  13. 在线考试小程序版手机微信考试软件,微信小程序考试系统出考试题小程序,考试答题微信小程序
  14. 腾讯面试:我倒在了网络基础知识
  15. EMC设计经典15问
  16. html title中加图标,科技常识:HTML中title前面小图标的实现_如何给网页标题添加icon小图标...
  17. Lightly 在线编译
  18. 利用DICOM文件实现2D与3D体素坐标之间的转换
  19. 防抄袭软件防抄袭系统反抄袭系统-推荐
  20. java的tey语句return了_java中try-catch-finally中的return语句

热门文章

  1. linux常用快捷命令(不断更新)
  2. 中国农科院微生物生态和进化方向博士后招聘(有高通量数据分析经验者优先)...
  3. NBT:牛瘤胃微生物组的4941个宏基因组组装基因组(MAG)
  4. 土壤生物多样性与生物化学过程研讨会(6.20-23合肥)
  5. Nature子刊:超高速细菌基因组检索技术
  6. 6月20日截止,请勿错过热心肠奖学金!
  7. QIIME 2教程. 11元数据Metadata(2020.11)
  8. 单细胞转录组专题研讨会第二期
  9. 水稻微生物组时间序列分析精讲1-模式图与主坐标轴分析
  10. Android酷欧天气实训报告书,萌新求助,第一行代码酷欧天气开发,遇到coolweather keeps s...