Leetcode-cn.com 2021-07-13
🔴 218.the-skyline-problem
🏷️ Tags
#binary_indexed_tree #segment_tree #array #divide_and_conquer #ordered_set #line_sweep #heap_priority_queue
Description
城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。给你所有建筑物的位置和高度,请返回由这些建筑物形成的 天际线 。
每个建筑物的几何信息由数组
天际线 应该表示为由 “关键点” 组成的列表,格式
注意:输出天际线中不得有连续的相同高度的水平线。例如
Example
🔴 218.the-skyline-problem
🏷️ Tags
#binary_indexed_tree #segment_tree #array #divide_and_conquer #ordered_set #line_sweep #heap_priority_queue
Description
城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。给你所有建筑物的位置和高度,请返回由这些建筑物形成的 天际线 。
每个建筑物的几何信息由数组
buildings 表示,其中三元组 buildings[i] = [lefti, righti, heighti] 表示:lefti 是第 i 座建筑物左边缘的 x 坐标。righti 是第 i 座建筑物右边缘的 x 坐标。heighti 是第 i 座建筑物的高度。天际线 应该表示为由 “关键点” 组成的列表,格式
[[x1,y1],[x2,y2],...] ,并按 x 坐标 进行 排序 。关键点是水平线段的左端点。列表中最后一个点是最右侧建筑物的终点,y 坐标始终为 0 ,仅用于标记天际线的终点。此外,任何两个相邻建筑物之间的地面都应被视为天际线轮廓的一部分。注意:输出天际线中不得有连续的相同高度的水平线。例如
[...[2 3], [4 5], [7 5], [11 5], [12 7]...] 是不正确的答案;三条高度为 5 的线应该在最终输出中合并为一个:[...[2 3], [4 5], [12 7], ...]Example
输入:buildings = [[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]
输出:[[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]
解释:
图 A 显示输入的所有建筑物的位置和高度,
图 B 显示由这些建筑物形成的天际线。图 B 中的红点表示输出列表中的关键点。
Leetcode.com 2021-08-22
🔴 850.rectangle-area-ii
🏷️ Tags
#segment_tree #array #ordered_set #line_sweep
Description
We are given a list of (axis-aligned)
Find the total area covered by all
Example
🔴 850.rectangle-area-ii
🏷️ Tags
#segment_tree #array #ordered_set #line_sweep
Description
We are given a list of (axis-aligned)
rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] , where (xi1, yi1) are the coordinates of the bottom-left corner, and (xi2, yi2) are the coordinates of the top-right corner of the ith rectangle.Find the total area covered by all
rectangles in the plane. Since the answer may be too large, return it modulo 109 + 7.Example
Input: rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
Output: 6
Explanation: As illustrated in the picture.
Leetcode-cn.com 2021-11-16
🔴 391.perfect-rectangle
🏷️ Tags
#array #line_sweep
Description
给你一个数组
如果所有矩形一起精确覆盖了某个矩形区域,则返回
Example
🔴 391.perfect-rectangle
🏷️ Tags
#array #line_sweep
Description
给你一个数组
rectangles ,其中 rectangles[i] = [xi, yi, ai, bi] 表示一个坐标轴平行的矩形。这个矩形的左下顶点是 (xi, yi) ,右上顶点是 (ai, bi) 。如果所有矩形一起精确覆盖了某个矩形区域,则返回
true ;否则,返回 false 。Example
输入:rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]
输出:true
解释:5 个矩形一起可以精确地覆盖一个矩形区域。
218.the-skyline-problem.pdf
210.7 KB
leetcode.com 2022-09-30
🔴218.the-skyline-problem
🏷️ Tags
#array #divide_and_conquer #binary_indexed_tree #segment_tree #line_sweep #heap_priority_queue #ordered_set
🔴218.the-skyline-problem
🏷️ Tags
#array #divide_and_conquer #binary_indexed_tree #segment_tree #line_sweep #heap_priority_queue #ordered_set
leetcode.cn 2023-07-18
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
Telegraph
minimum-interval-to-include-each-query
给你一个二维整数数组 intervals ,其中 intervals[i] = [lefti, righti] 表示第 i 个区间开始于 lefti 、结束于 righti(包含两侧取值,闭区间)。区间的 长度 定义为区间中包含的整数数目,更正式地表达是 righti - lefti + 1 。 再给你一个整数数组 queries 。第 j 个查询的答案是满足 lefti <= queries[j] <= righti 的 长度最小区间 i 的长度 。如果不存在这样的区间,那么答案是 -1 。 以数组形式返回对应查询的所有答案。…