Avatar

Organizations

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

    leetcode 困难 树状数组 线段树 数组 Created Sun, 25 Dec 2022 20:56:06 +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
  • 给你两个下标从 0  开始且长度为 n  的整数数组  nums1  和  nums2 ,两者都是  [0, 1, ..., n - 1]  的  排列 。

    好三元组 指的是  3  个  互不相同  的值,且它们在数组  nums1 和  nums2  中出现顺序保持一致。换句话说,如果我们将  \(pos1_v\) 记为值  v  在  nums1  中出现的位置,\(pos2_v\  为值  v  在  nums2  中的位置,那么一个好三元组定义为  0 <= x, y, z <= n - 1 ,且  \(pos1_x < pos1_y < pos1_z\) 和  \(pos2_x < pos2_y < pos2_z\)  都成立的  (x, y, z) 。

    请你返回好三元组的 总数目 。

    leetcode 困难 树状数组 Created Sun, 20 Feb 2022 09:30:44 +0800