原文链接: https://leetcode-cn.com/problems/merge-k-sorted-lists 英文原文You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lis…
标签详情
堆(优先队列) 分类
原文链接: https://leetcode-cn.com/problems/kth-largest-element-in-an-array 英文原文Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct el…
原文链接: 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/sliding-window-maximum 英文原文You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the wi…
原文链接: https://leetcode-cn.com/problems/ugly-number-ii 英文原文An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the nth ugly number. Example 1: Input: n = 10 Output: 12 Explanation: [1, 2, 3, …
原文链接: https://leetcode-cn.com/problems/find-median-from-data-stream 英文原文The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. For exam…
原文链接: https://leetcode-cn.com/problems/top-k-frequent-elements 英文原文Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] …
原文链接: https://leetcode-cn.com/problems/design-twitter 英文原文Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed. Implement the Twitter cl…
原文链接: https://leetcode-cn.com/problems/find-k-pairs-with-smallest-sums 英文原文You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u, v) which consists of one element from the first array and one el…
原文链接: https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix 英文原文Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest …
原文链接: https://leetcode-cn.com/problems/trapping-rain-water-ii 英文原文Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining. Example 1: Input: heightM…
原文链接: https://leetcode-cn.com/problems/strong-password-checker 英文原文A password is considered strong if the below conditions are all met: It has at least 6 characters and at most 20 characters. It contains at least one lowercase letter, at least one up…
原文链接: https://leetcode-cn.com/problems/sort-characters-by-frequency 英文原文Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the s…
原文链接: https://leetcode-cn.com/problems/sliding-window-median 英文原文The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values. For examples, i…
原文链接: https://leetcode-cn.com/problems/ipo 英文原文Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has…
原文链接: https://leetcode-cn.com/problems/relative-ranks 英文原文You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on th…
原文链接: https://leetcode-cn.com/problems/task-scheduler 英文原文Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time…
原文链接: https://leetcode-cn.com/problems/course-schedule-iii 英文原文There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuousl…
原文链接: https://leetcode-cn.com/problems/smallest-range-covering-elements-from-k-lists 英文原文You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists. We define the ra…
原文链接: https://leetcode-cn.com/problems/find-k-closest-elements 英文原文Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to…
原文链接: https://leetcode-cn.com/problems/split-array-into-consecutive-subsequences 英文原文You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of…
原文链接: https://leetcode-cn.com/problems/cut-off-trees-for-golf-event 英文原文You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix: 0 means the cell cannot be walked through. 1 re…
原文链接: https://leetcode-cn.com/problems/top-k-frequent-words 英文原文Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequ…
原文链接: https://leetcode-cn.com/problems/network-delay-time 英文原文You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the …
原文链接: https://leetcode-cn.com/problems/reorganize-string 英文原文Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: …
原文链接: https://leetcode-cn.com/problems/kth-largest-element-in-a-stream 英文原文Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest cla…
原文链接: https://leetcode-cn.com/problems/swim-in-rising-water 英文原文You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). The rain starts to fall. At time t, the depth of the water everywher…
原文链接: https://leetcode-cn.com/problems/k-th-smallest-prime-fraction 英文原文You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k. For every i and j where 0 <= i…
原文链接: https://leetcode-cn.com/problems/cheapest-flights-within-k-stops 英文原文There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-hire-k-workers 英文原文There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith…
1 / 3