原文链接: https://leetcode-cn.com/problems/minimum-number-of-refueling-stops 英文原文A car travels from a starting position to a destination which is target miles east of the starting position. There are gas stations along the way. The gas stations are repre…
标签详情
堆(优先队列) 分类
原文链接: https://leetcode-cn.com/problems/shortest-subarray-with-sum-at-least-k 英文原文Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return…
原文链接: https://leetcode-cn.com/problems/reachable-nodes-in-subdivided-graph 英文原文You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with t…
原文链接: https://leetcode-cn.com/problems/sort-an-array 英文原文Given an array of integers nums, sort the array in ascending order. Example 1: Input: nums = [5,2,3,1] Output: [1,2,3,5] Example 2: Input: nums = [5,1,1,2,0,0] Output: [0,0,1,1,2,5] Constraints…
原文链接: https://leetcode-cn.com/problems/k-closest-points-to-origin 英文原文Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two…
原文链接: https://leetcode-cn.com/problems/last-stone-weight 英文原文You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash th…
原文链接: https://leetcode-cn.com/problems/distant-barcodes 英文原文In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i]. Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guar…
原文链接: https://leetcode-cn.com/problems/car-pooling 英文原文There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer capacity and an array trips where trip[i] = [numPass…
原文链接: https://leetcode-cn.com/problems/dinner-plate-stacks 英文原文You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Implement the DinnerPlates class: DinnerPlat…
原文链接: https://leetcode-cn.com/problems/constrained-subsequence-sum 英文原文Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums…
原文链接: https://leetcode-cn.com/problems/longest-happy-string 英文原文A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring. Given three integers a, b and c, return any string s, which satisfies following cond…
原文链接: https://leetcode-cn.com/problems/path-with-maximum-probability 英文原文You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a …
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-move-a-box-to-their-target-location 英文原文A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations. The game is represented by an m x n…
原文链接: https://leetcode-cn.com/problems/the-k-weakest-rows-in-a-matrix 英文原文You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all th…
原文链接: https://leetcode-cn.com/problems/reduce-array-size-to-the-half 英文原文You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-events-that-can-be-attended 英文原文Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at any day d wh…
原文链接: https://leetcode-cn.com/problems/construct-target-array-with-multiple-sums 英文原文You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure : let x be the sum of all element…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid 英文原文Given a m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j…
原文链接: https://leetcode-cn.com/problems/pizza-with-3n-slices 英文原文There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows: You will pick any pizza slice. Your friend Alice will pick next slice in anti …
原文链接: https://leetcode-cn.com/problems/maximum-performance-of-a-team 英文原文You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse-ii 英文原文Given a list of lists of integers, nums, return all elements of nums in diagonal order as shown in the below images. Example 1: Input: nums = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,4,2,7,5…
原文链接: 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-the-kth-smallest-sum-of-a-matrix-with-sorted-rows 英文原文You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order. You are allowed to choose exactly 1 element fro…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-two-elements-in-an-array 英文原文Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/avoid-flood-in-the-city 英文原文Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake whic…
原文链接: https://leetcode-cn.com/problems/max-value-of-equation 英文原文You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.lengt…
原文链接: 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/path-with-minimum-effort 英文原文You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are si…
原文链接: https://leetcode-cn.com/problems/furthest-building-you-can-reach 英文原文You are given an integer array heights representing the heights of buildings, some bricks, and some ladders. You start your journey from building 0 and move to the next buildi…
原文链接: https://leetcode-cn.com/problems/sell-diminishing-valued-colored-balls 英文原文You have an inventory of different colored balls, and there is a customer that wants orders balls of any color. The customer weirdly values the colored balls. Each color…