原文链接: https://leetcode-cn.com/problems/the-skyline-problem 英文原文A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return …
标签详情
树状数组 分类
原文链接: https://leetcode-cn.com/problems/range-sum-query-mutable 英文原文Given an integer array nums, handle multiple queries of the following types: Update the value of an element in nums. Calculate the sum of the elements of nums between indices left and…
原文链接: https://leetcode-cn.com/problems/count-of-smaller-numbers-after-self 英文原文You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the r…
原文链接: https://leetcode-cn.com/problems/count-of-range-sum 英文原文Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements …
原文链接: https://leetcode-cn.com/problems/reverse-pairs 英文原文Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j]. Example 1: Input: nums = …
原文链接: https://leetcode-cn.com/problems/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…
原文链接: https://leetcode-cn.com/problems/online-majority-element-in-subarray 英文原文Design a data structure that efficiently finds the majority element of a given subarray. The majority element of a subarray is an element that occurs threshold times or mo…
原文链接: https://leetcode-cn.com/problems/count-number-of-teams 英文原文There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the following rules: Choose 3 soldiers …
原文链接: https://leetcode-cn.com/problems/queries-on-a-permutation-with-key 英文原文Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: In the be…
原文链接: https://leetcode-cn.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits 英文原文Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the i…
原文链接: https://leetcode-cn.com/problems/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 …
原文链接: https://leetcode-cn.com/problems/coin-bonus 中文题目力扣决定给一个刷题团队发LeetCoin作为奖励。同时,为了监控给大家发了多少LeetCoin,力扣有时候也会进行查询。 该刷题团队的管理模式可以用一棵树表示: 团队只有一个负责人,编号为1。除了该负责人外,每个人有且仅有一个领导(负责人没有领导); 不存在循环管理的情况,如A管理B,B管理C,C管理A。 力扣想进行的操作有以下三种: 给团队的一个成员(也可以是负责人)发一定数量的Leet…
原文链接: https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof 中文题目在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。 示例 1: 输入: [7,5,6,4] 输出: 5 限制: 0 <= 数组长度 <= 50000 通过代码 高赞题解📺 视频题解 📖 文字题解方法一:归并排序预备知识 「归并排序」是分治思想的典型应用,它包含这样三个步骤:…
原文链接: https://leetcode-cn.com/problems/rank-from-stream-lcci 英文原文Imagine you are reading in a stream of integers. Periodically, you wish to be able to look up the rank of a number x (the number of values less than or equal to x). lmplement the data s…