原文链接: 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/contains-duplicate-iii 英文原文Given an integer array nums and two integers k and t, return true if there are two distinct indices i and j in the array such that abs(nums[i] - nums[j]) <= t and abs(i - j) <= k. Exam…
原文链接: 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/data-stream-as-disjoint-intervals 英文原文Given a data stream input of non-negative integers a1, a2, ..., an, summarize the numbers seen so far as a list of disjoint intervals. Implement the SummaryRanges class: Sum…
原文链接: https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k 英文原文Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k. It is guaranteed that there will be…
原文链接: https://leetcode-cn.com/problems/132-pattern 英文原文Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132…
原文链接: 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/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/exam-room 英文原文There is an exam room with n seats in a single row labeled from 0 to n - 1. When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there are…
原文链接: https://leetcode-cn.com/problems/random-point-in-non-overlapping-rectangles 英文原文You are given an array of non-overlapping axis-aligned rectangles rects where rects[i] = [ai, bi, xi, yi] indicates that (ai, bi) is the bottom-left corner point of…
原文链接: https://leetcode-cn.com/problems/maximum-frequency-stack 英文原文Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequ…
原文链接: https://leetcode-cn.com/problems/odd-even-jump 英文原文You are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th,…
原文链接: https://leetcode-cn.com/problems/tweet-counts-per-frequency 英文原文A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into sma…
原文链接: https://leetcode-cn.com/problems/display-table-of-food-orders-in-a-restaurant 英文原文Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] w…
原文链接: https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit 英文原文Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute diffe…
原文链接: https://leetcode-cn.com/problems/find-servers-that-handled-most-number-of-requests 英文原文You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but…
原文链接: https://leetcode-cn.com/problems/design-movie-rental-system 英文原文You have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning movies. The system should also su…
原文链接: https://leetcode-cn.com/problems/the-number-of-the-smallest-unoccupied-chair 英文原文There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. …
原文链接: https://leetcode-cn.com/problems/stock-price-fluctuation 英文原文You are given a stream of records about a particular stock. Each record contains a timestamp and the corresponding price of the stock at that timestamp. Unfortunately due to the volat…
原文链接: https://leetcode-cn.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference 英文原文You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of…
原文链接: 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/IQvJ9i 英文原文 中文题目秋日市集上有个奇怪的黑盒,黑盒的主视图为 n\*m 的矩形。从黑盒的主视图来看,黑盒的上面和下面各均匀分布有 m 个小孔,黑盒的左面和右面各均匀分布有 n 个小孔。黑盒左上角小孔序号为 0,按顺时针编号,总共有 2*(m+n) 个小孔。每个小孔均可以打开或者关闭,初始时,所有小孔均处于关闭状态。每个小孔上的盖子均为镜面材质。例如一个 2\*3 的黑盒主视图与其小孔分布如图所示: {:he…
原文链接: https://leetcode-cn.com/problems/7WqeDu 中文题目给你一个整数数组 nums 和两个整数 k 和 t 。请你判断是否存在 两个不同下标 i 和 j,使得 abs(nums[i] - nums[j]) <= t ,同时又满足 abs(i - j) <= k 。 如果存在则返回 true,不存在返回 false。 示例 1: 输入:nums = [1,2,3,1], k = 3, t = 0 输出:true 示例 2: 输入:nums = [1,0,…
原文链接: https://leetcode-cn.com/problems/fi9suh 中文题目请实现一个 MyCalendar 类来存放你的日程安排。如果要添加的时间内没有其他安排,则可以存储这个新的日程安排。 MyCalendar 有一个 book(int start, int end)方法。它意味着在 start 到 end 时间内增加一个日程安排,注意,这里的时间是半开区间,即 [start, end), 实数 x 的范围为, start <= x < end。 当两个日程安排有一些…