Avatar

Organizations

4 results for 线段树
  • 城市的 天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。给你所有建筑物的位置和高度,请返回 *由这些建筑物形成的 天际线*

    leetcode 困难 树状数组 线段树 数组 Created Sun, 25 Dec 2022 20:56:06 +0800
  • Range 模块是跟踪数字范围的模块。设计一个数据结构来跟踪表示为 半开区间的范围并查询它们。

    半开区间 [left, right)  表示所有  left <= x < right  的实数 x

    实现 RangeModule 类:

    • RangeModule()  初始化数据结构的对象。
    • void addRange(int left, int right) 添加 半开区间 [left, right),跟踪该区间中的每个实数。添加与当前跟踪的数字部分重叠的区间时,应当添加在区间  [left, right)  中尚未跟踪的任何数字到该区间中。
    • boolean queryRange(int left, int right)  只有在当前正在跟踪区间  [left, right)  中的每一个实数时,才返回true ,否则返回 false
    • void removeRange(int left, int right)  停止跟踪 半开区间 [left, right)  中当前正在跟踪的每个实数。
    leetcode 困难 设计 线段树 有序集合 Created Mon, 19 Sep 2022 21:11:46 +0800
  • 给你一个整数数组 nums ,按要求返回一个新数组  counts 。数组 counts 有该性质: counts[i] 的值是   nums[i] 右侧小于  nums[i] 的元素的数量。

    leetcode 困难 树状数组 线段树 数组 Created Wed, 07 Sep 2022 13:47:35 +0800
  • Given an integer array nums, handle multiple queries of the following types:

    1. Update the value of an element in nums.
    2. Calculate the sum of the elements of nums between indices left and right inclusive where left <= right.

    Implement the NumArray class:

    • NumArray(int[] nums) Initializes the object with the integer array nums.
    • void update(int index, int val) Updates the value of nums[index] to be val.
    • int sumRange(int left, int right) Returns the sum of the elements of nums between indices left and right inclusive (i.e. nums[left] + nums[left + 1] + ... + nums[right]).
    leetcode 中等 设计 树状数组 线段树 Created Mon, 04 Apr 2022 12:46:58 +0800