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-cn.com 2021-09-20
🟡 673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
Description
给定一个未排序的整数数组,找到最长递增子序列的个数。
Example
🟡 673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
Description
给定一个未排序的整数数组,找到最长递增子序列的个数。
Example
输入: [1,3,5,4,7]
输出: 2
解释: 有两个最长递增子序列,分别是 [1, 3, 4, 7] 和[1, 3, 5, 7]。
Leetcode-cn.com 2022-04-04
🟡 307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
Description
给你一个数组
其中一类查询要求 更新 数组
另一类查询要求返回数组
实现
Example
🟡 307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
Description
给你一个数组
nums ,请你完成两类查询。其中一类查询要求 更新 数组
nums 下标对应的值另一类查询要求返回数组
nums 中索引 left 和索引 right 之间( 包含 )的nums元素的 和 ,其中 left <= right实现
NumArray 类:NumArray(int[] nums) 用整数数组 nums 初始化对象void update(int index, int val) 将 nums[index] 的值 更新 为 valint sumRange(int left, int right) 返回数组 nums 中索引 left 和索引 right 之间( 包含 )的nums元素的 和 (即,nums[left] + nums[left + 1], ..., nums[right])Example
输入:
["NumArray", "sumRange", "update", "sumRange"]
[[[1, 3, 5]], [0, 2], [1, 2], [0, 2]]
输出:
[null, 9, null, 8]
解释:
NumArray numArray = new NumArray([1, 3, 5]);
numArray.sumRange(0, 2); // 返回 1 + 3 + 5 = 9
numArray.update(1, 2); // nums = [1,2,5]
numArray.sumRange(0, 2); // 返回 1 + 2 + 5 = 8
307.range-sum-query-mutable.pdf
63 KB
leetcode.com 2022-07-31
🟡307.range-sum-query-mutable
🏷️ Tags
#array #design #binary_indexed_tree #segment_tree
🟡307.range-sum-query-mutable
🏷️ Tags
#array #design #binary_indexed_tree #segment_tree
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-04-16
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
Telegraph
online-majority-element-in-subarray
设计一个数据结构,有效地找到给定子数组的 多数元素 。 子数组的 多数元素 是在子数组中出现 threshold 次数或次数以上的元素。 实现 MajorityChecker 类:
leetcode.com 2023-05-07
🔴1964.find-the-longest-valid-obstacle-course-at-each-position
🏷️ Tags
#binary_indexed_tree #array #binary_search
🔴1964.find-the-longest-valid-obstacle-course-at-each-position
🏷️ Tags
#binary_indexed_tree #array #binary_search
Telegraph
find-the-longest-valid-obstacle-course-at-each-position
You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle. For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle…
leetcode.com 2023-07-21
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
Telegraph
number-of-longest-increasing-subsequence
Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4,…
leetcode.cn 2023-11-13
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
Telegraph
range-sum-query-mutable
给你一个数组 nums ,请你完成两类查询。
leetcode.cn 2023-11-17
🔴2736.maximum-sum-queries
🏷️ Tags
#stack #binary_indexed_tree #segment_tree #array #binary_search #sorting #monotonic_stack
🔴2736.maximum-sum-queries
🏷️ Tags
#stack #binary_indexed_tree #segment_tree #array #binary_search #sorting #monotonic_stack
Telegraph
maximum-sum-queries
给你两个长度为 n 、下标从 0 开始的整数数组 nums1 和 nums2 ,另给你一个下标从 1 开始的二维数组 queries ,其中 queries[i] = [xi, yi] 。 对于第 i 个查询,在所有满足 nums1[j] >= xi 且 nums2[j] >= yi 的下标 j (0 <= j < n) 中,找出 nums1[j] + nums2[j] 的 最大值 ,如果不存在满足条件的 j 则返回 -1 。 返回数组 answer ,其中 answer[i] 是第 i 个查询的答案。…
leetcode.cn 2025-04-15
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
Telegraph
count-good-triplets-in-an-array
给你两个下标从 0 开始且长度为 n 的整数数组 nums1 和 nums2 ,两者都是 [0, 1, ..., n - 1] 的 排列 。 好三元组 指的是 3 个 互不相同 的值,且它们在数组 nums1 和 nums2 中出现顺序保持一致。换句话说,如果我们将 pos1v 记为值 v 在 nums1 中出现的位置,pos2v 为值 v 在 nums2 中的位置,那么一个好三元组定义为 0 <= x, y, z <= n - 1 ,且 pos1x < pos1y < pos1z 和 pos2x < pos2y…
leetcode.com 2025-04-15
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
Telegraph
count-good-triplets-in-an-array
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1]. A good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if…
👍1