原文链接: 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/falling-squares 英文原文There are several squares being dropped onto the X-axis of a 2D plane. You are given a 2D integer array positions where positions[i] = [lefti, sideLengthi] represents the ith square with a si…
原文链接: https://leetcode-cn.com/problems/my-calendar-i 英文原文You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking happens when two events have some non-empty …
原文链接: https://leetcode-cn.com/problems/my-calendar-ii 英文原文You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking. A triple booking happens when three events have some non-emp…
原文链接: https://leetcode-cn.com/problems/my-calendar-iii 英文原文A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.) You are given some events [start, end), after each given event, r…
原文链接: https://leetcode-cn.com/problems/rectangle-area-ii 英文原文You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coordinates of the bottom-left corner, and (…
原文链接: 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/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/fancy-sequence 英文原文Write an API that generates fancy sequences using the append, addAll, and multAll operations. Implement the Fancy class: Fancy() Initializes the object with an empty sequence. void append(val)…
原文链接: 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/zui-xiao-tiao-yue-ci-shu 英文原文 中文题目为了给刷题的同学一些奖励,力扣团队引入了一个弹簧游戏机。游戏机由 N 个特殊弹簧排成一排,编号为 0 到 N-1。初始有一个小球在编号 0 的弹簧处。若小球在编号为 i 的弹簧处,通过按动弹簧,可以选择把小球向右弹射 jump[i] 的距离,或者向左弹射到任意左侧弹簧的位置。也就是说,在编号为 i 弹簧处按动弹簧,小球可以弹向 0 到 i-1 中任意弹…
原文链接: https://leetcode-cn.com/problems/IQvJ9i 英文原文 中文题目秋日市集上有个奇怪的黑盒,黑盒的主视图为 n\*m 的矩形。从黑盒的主视图来看,黑盒的上面和下面各均匀分布有 m 个小孔,黑盒的左面和右面各均匀分布有 n 个小孔。黑盒左上角小孔序号为 0,按顺时针编号,总共有 2*(m+n) 个小孔。每个小孔均可以打开或者关闭,初始时,所有小孔均处于关闭状态。每个小孔上的盖子均为镜面材质。例如一个 2\*3 的黑盒主视图与其小孔分布如图所示: {:he…
原文链接: https://leetcode-cn.com/problems/fi9suh 中文题目请实现一个 MyCalendar 类来存放你的日程安排。如果要添加的时间内没有其他安排,则可以存储这个新的日程安排。 MyCalendar 有一个 book(int start, int end)方法。它意味着在 start 到 end 时间内增加一个日程安排,注意,这里的时间是半开区间,即 [start, end), 实数 x 的范围为, start <= x < end。 当两个日程安排有一些…