Heap (Priority Queue) Problems
Master heap (priority queue) problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 131 problems in this category.
Total Problems: 131
Easy: 13
Medium: 73
Hard: 45
Showing 50 of 131 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Heap (Priority Queue) LeetCode Problems List
- 347. Top K Frequent Elements - Medium - Heap (Priority Queue)Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.... Topics: Array, Hash Table, Divide and Conquer, Sorting, Heap (Priority Queue), Bucket Sort, Counting, Quickselect
- 1014. K Closest Points to Origin - Medium - Heap (Priority Queue)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... Topics: Array, Math, Divide and Conquer, Geometry, Sorting, Heap (Priority Queue), Quickselect
- 23. Merge k Sorted Lists - Hard - Heap (Priority Queue)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 ... Topics: Linked List, Divide and Conquer, Heap (Priority Queue), Merge Sort
- 803. Cheapest Flights Within K Stops - Medium - Heap (Priority Queue)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... Topics: Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 378. Kth Smallest Element in a Sorted Matrix - Medium - Heap (Priority Queue)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 ... Topics: Array, Binary Search, Sorting, Heap (Priority Queue), Matrix
- 295. Find Median from Data Stream - Hard - Heap (Priority Queue)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 th... Topics: Two Pointers, Design, Sorting, Heap (Priority Queue), Data Stream
- 630. Course Schedule III - Hard - Heap (Priority Queue)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 i... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 215. Kth Largest Element in an Array - Medium - Heap (Priority Queue)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... Topics: Array, Divide and Conquer, Sorting, Heap (Priority Queue), Quickselect
- 239. Sliding Window Maximum - Hard - Heap (Priority Queue)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 ca... Topics: Array, Queue, Sliding Window, Heap (Priority Queue), Monotonic Queue
- 621. Task Scheduler - Medium - Heap (Priority Queue)You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of ... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Counting
- 2479. Meeting Rooms III - Hard - Heap (Priority Queue)You are given an integer n. There are n rooms numbered from 0 to n - 1. You are given a 2D integer array meetings where meetings[i] = [starti, endi] m... Topics: Array, Hash Table, Sorting, Heap (Priority Queue), Simulation
- 355. Design Twitter - Medium - Heap (Priority Queue)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 ... Topics: Hash Table, Linked List, Design, Heap (Priority Queue)
- 658. Find K Closest Elements - Medium - Heap (Priority Queue)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... Topics: Array, Two Pointers, Binary Search, Sliding Window, Sorting, Heap (Priority Queue)
- 948. Sort an Array - Medium - Heap (Priority Queue)Given an array of integers nums, sort the array in ascending order and return it. You must solve the problem without using any built-in functions in O... Topics: Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort
- 794. Swim in Rising Water - Hard - Heap (Priority Queue)You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). It starts raining, and water gra... Topics: Array, Binary Search, Depth-First Search, Breadth-First Search, Union Find, Heap (Priority Queue), Matrix
- 420. Strong Password Checker - Hard - Heap (Priority Queue)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 ... Topics: String, Greedy, Heap (Priority Queue)
- 3863. Power Grid Maintenance - Medium - Heap (Priority Queue)You are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing). These stations are intercon... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph, Heap (Priority Queue), Ordered Set
- 1127. Last Stone Weight - Easy - Heap (Priority Queue)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 choo... Topics: Array, Heap (Priority Queue)
- 744. Network Delay Time - Medium - Heap (Priority Queue)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), w... Topics: Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 885. Exam Room - Medium - Heap (Priority Queue)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 t... Topics: Design, Heap (Priority Queue), Ordered Set
- 451. Sort Characters By Frequency - Medium - Heap (Priority Queue)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... Topics: Hash Table, String, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 1814. Jump Game VI - Medium - Heap (Priority Queue)You are given a 0-indexed integer array nums and an integer k. You are initially standing at index 0. In one move, you can jump at most k steps forwar... Topics: Array, Dynamic Programming, Queue, Heap (Priority Queue), Monotonic Queue
- 659. Split Array into Consecutive Subsequences - Medium - Heap (Priority Queue)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 su... Topics: Array, Hash Table, Greedy, Heap (Priority Queue)
- 2868. Continuous Subarrays - Medium - Heap (Priority Queue)You are given a 0-indexed integer array nums. A subarray of nums is called continuous if: Let i, i + 1, ..., j be the indices in the subarray. Then, f... Topics: Array, Queue, Sliding Window, Heap (Priority Queue), Ordered Set, Monotonic Queue
- 218. The Skyline Problem - Hard - Heap (Priority Queue)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 ... Topics: Array, Divide and Conquer, Binary Indexed Tree, Segment Tree, Line Sweep, Heap (Priority Queue), Ordered Set
- 407. Trapping Rain Water II - Hard - Heap (Priority Queue)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 ... Topics: Array, Breadth-First Search, Heap (Priority Queue), Matrix
- 1478. Maximum Number of Events That Can Be Attended - Medium - Heap (Priority Queue)You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an even... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 789. Kth Largest Element in a Stream - Easy - Heap (Priority Queue)You are part of a university admissions office and need to keep track of the kth highest test score from applicants in real-time. This helps to determ... Topics: Tree, Design, Binary Search Tree, Heap (Priority Queue), Binary Tree, Data Stream
- 2161. Stock Price Fluctuation - Medium - Heap (Priority Queue)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 timestam... Topics: Hash Table, Design, Heap (Priority Queue), Data Stream, Ordered Set
- 1184. Car Pooling - Medium - Heap (Priority Queue)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 capacit... Topics: Array, Sorting, Heap (Priority Queue), Simulation, Prefix Sum
- 373. Find K Pairs with Smallest Sums - Medium - Heap (Priority Queue)You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k. Define a pair (u, v) which consists of one element f... Topics: Array, Heap (Priority Queue)
- 1397. Search Suggestions System - Medium - Heap (Priority Queue)You are given an array of strings products and a string searchWord. Design a system that suggests at most three product names from products after each... Topics: Array, String, Binary Search, Trie, Sorting, Heap (Priority Queue)
- 2113. Find the Kth Largest Integer in the Array - Medium - Heap (Priority Queue)You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros. Return the string that repre... Topics: Array, String, Divide and Conquer, Sorting, Heap (Priority Queue), Quickselect
- 2204. Find Subsequence of Length K With the Largest Sum - Easy - Heap (Priority Queue)You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum. Return any such sub... Topics: Array, Hash Table, Sorting, Heap (Priority Queue)
- 1304. Longest Happy String - Medium - Heap (Priority Queue)A string s is called happy if it satisfies the following conditions: s only contains the letters 'a', 'b', and 'c'. s does not contain any of "aaa", "... Topics: String, Greedy, Heap (Priority Queue)
- 480. Sliding Window Median - Hard - Heap (Priority Queue)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... Topics: Array, Hash Table, Sliding Window, Heap (Priority Queue)
- 2250. K Highest Ranked Items Within a Price Range - Medium - Heap (Priority Queue)You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the fol... Topics: Array, Breadth-First Search, Sorting, Heap (Priority Queue), Matrix
- 2488. Divide Intervals Into Minimum Number of Groups - Medium - Heap (Priority Queue)You are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti]. You have to divide ... Topics: Array, Two Pointers, Greedy, Sorting, Heap (Priority Queue), Prefix Sum
- 3627. Find Minimum Time to Reach Last Room I - Medium - Heap (Priority Queue)There is a dungeon with n x m rooms arranged as a grid. You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum t... Topics: Array, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 1753. Path With Minimum Effort - Medium - Heap (Priority Queue)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 heigh... Topics: Array, Binary Search, Depth-First Search, Breadth-First Search, Union Find, Heap (Priority Queue), Matrix
- 892. Shortest Subarray with Sum at Least K - Hard - Heap (Priority Queue)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 su... Topics: Array, Binary Search, Queue, Sliding Window, Heap (Priority Queue), Prefix Sum, Monotonic Queue
- 2725. Mice and Cheese - Medium - Heap (Priority Queue)There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse. A point of the cheese with index i (0-in... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 2449. Maximum Number of Robots Within Budget - Hard - Heap (Priority Queue)You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] unit... Topics: Array, Binary Search, Queue, Sliding Window, Heap (Priority Queue), Prefix Sum, Monotonic Queue
- 506. Relative Ranks - Easy - Heap (Priority Queue)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 u... Topics: Array, Sorting, Heap (Priority Queue)
- 1902. Car Fleet II - Hard - Heap (Priority Queue)There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [... Topics: Array, Math, Stack, Heap (Priority Queue), Monotonic Stack
- 1549. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit - Medium - Heap (Priority Queue)Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any ... Topics: Array, Queue, Sliding Window, Heap (Priority Queue), Ordered Set, Monotonic Queue
- 1622. Max Value of Equation - Hard - Heap (Priority Queue)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... Topics: Array, Queue, Sliding Window, Heap (Priority Queue), Monotonic Queue
- 3496. Minimum Number of Seconds to Make Mountain Height Zero - Medium - Heap (Priority Queue)You are given an integer mountainHeight denoting the height of a mountain. You are also given an integer array workerTimes representing the work time ... Topics: Array, Math, Binary Search, Greedy, Heap (Priority Queue)
- 2429. Design a Food Rating System - Medium - Heap (Priority Queue)Design a food rating system that can do the following: Modify the rating of a food item listed in the system. Return the highest-rated food item for a... Topics: Array, Hash Table, String, Design, Heap (Priority Queue), Ordered Set
- 3181. Find Building Where Alice and Bob Can Meet - Hard - Heap (Priority Queue)You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building. If a person is in building i... Topics: Array, Binary Search, Stack, Binary Indexed Tree, Segment Tree, Heap (Priority Queue), Monotonic Stack
- 1499. Maximum Performance of a Team - Hard - Heap (Priority Queue)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] ... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 2686. Minimum Cost of a Path With Special Roads - Medium - Heap (Priority Queue)You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the ar... Topics: Array, Graph, Heap (Priority Queue), Shortest Path
- 2207. Sequentially Ordinal Rank Tracker - Hard - Heap (Priority Queue)A scenic location is represented by its name and attractiveness score, where name is a unique string among all locations and score is an integer. Loca... Topics: Design, Heap (Priority Queue), Data Stream, Ordered Set
- 1574. Maximum Product of Two Elements in an Array - Easy - Heap (Priority Queue)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).... Topics: Array, Sorting, Heap (Priority Queue)
- 2616. Maximal Score After Applying K Operations - Medium - Heap (Priority Queue)You are given a 0-indexed integer array nums and an integer k. You have a starting score of 0. In one operation: choose an index i such that 0 <= i < ... Topics: Array, Greedy, Heap (Priority Queue)
- 1962. Single-Threaded CPU - Medium - Heap (Priority Queue)You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means th... Topics: Array, Sorting, Heap (Priority Queue)
- 2636. Maximum Subsequence Score - Medium - Heap (Priority Queue)You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from n... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 502. IPO - Hard - Heap (Priority Queue)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... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 3919. Network Recovery Pathways - Hard - Heap (Priority Queue)You are given a directed acyclic graph of n nodes numbered from 0 to n − 1. This is represented by a 2D array edges of length m, where edges[i] = [ui,... Topics: Array, Binary Search, Dynamic Programming, Graph, Topological Sort, Heap (Priority Queue), Shortest Path
- 1539. Diagonal Traverse II - Medium - Heap (Priority Queue)Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.... Topics: Array, Sorting, Heap (Priority Queue)
- 632. Smallest Range Covering Elements from K Lists - Hard - Heap (Priority Queue)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 de... Topics: Array, Hash Table, Greedy, Sliding Window, Sorting, Heap (Priority Queue)
- 1710. Find Servers That Handled Most Number of Requests - Hard - Heap (Priority Queue)You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capac... Topics: Array, Greedy, Heap (Priority Queue), Ordered Set
- 2590. Maximum Star Sum of a Graph - Medium - Heap (Priority Queue)There is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] de... Topics: Array, Greedy, Graph, Sorting, Heap (Priority Queue)
- 1771. Sell Diminishing-Valued Colored Balls - Medium - Heap (Priority Queue)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 colore... Topics: Array, Math, Binary Search, Greedy, Sorting, Heap (Priority Queue)
- 1485. Minimum Cost to Make at Least One Valid Path in a Grid - Hard - Heap (Priority Queue)Given an 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... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 3959. Maximum Total from Optimal Activation Order - Medium - Heap (Priority Queue)You are given two integer arrays value and limit, both of length n. Initially, all elements are inactive. You may activate them in any order. To activ... Topics: Array, Two Pointers, Greedy, Sorting, Heap (Priority Queue)
- 3916. Minimum Time to Reach Destination in Directed Graph - Medium - Heap (Priority Queue)You are given an integer n and a directed graph with n nodes labeled from 0 to n - 1. This is represented by a 2D array edges, where edges[i] = [ui, v... Topics: Graph, Heap (Priority Queue), Shortest Path
- 2267. Minimum Difference in Sums After Removal of Elements - Hard - Heap (Priority Queue)You are given a 0-indexed integer array nums consisting of 3 * n elements. You are allowed to remove any subsequence of elements of size exactly n fro... Topics: Array, Dynamic Programming, Heap (Priority Queue)
- 2588. Maximum Number of Points From Grid Queries - Hard - Heap (Priority Queue)You are given an m x n integer matrix grid and an array queries of size k. Find an array answer of size k such that for each integer queries[i] you st... Topics: Array, Two Pointers, Breadth-First Search, Union Find, Sorting, Heap (Priority Queue), Matrix
- 1955. Seat Reservation Manager - Medium - Heap (Priority Queue)Design a system that manages the reservation state of n seats that are numbered from 1 to n. Implement the SeatManager class: SeatManager(int n) Initi... Topics: Design, Heap (Priority Queue)
- 2054. The Number of the Smallest Unoccupied Chair - Medium - Heap (Priority Queue)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 ... Topics: Array, Hash Table, Heap (Priority Queue)
- 2681. Put Marbles in Bags - Hard - Heap (Priority Queue)You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k. D... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 1824. Maximum Number of Eaten Apples - Medium - Heap (Priority Queue)There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days... Topics: Array, Greedy, Heap (Priority Queue)
- 2603. Reward Top K Students - Medium - Heap (Priority Queue)You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. N... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
- 1928. Number of Orders in the Backlog - Medium - Heap (Priority Queue)You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type ord... Topics: Array, Heap (Priority Queue), Simulation
- 2678. Design Graph With Shortest Path Calculator - Hard - Heap (Priority Queue)There is a directed weighted graph that consists of n nodes numbered from 0 to n - 1. The edges of the graph are initially represented by the given ar... Topics: Graph, Design, Heap (Priority Queue), Shortest Path
- 692. Top K Frequent Words - Medium - Heap (Priority Queue)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... Topics: Array, Hash Table, String, Trie, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 2914. Find the Safest Path in a Grid - Medium - Heap (Priority Queue)You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents: A cell containing a thief if grid[r][c] = 1 An empty cell if grid[r][... Topics: Array, Binary Search, Breadth-First Search, Union Find, Heap (Priority Queue), Matrix
- 918. Reachable Nodes In Subdivided Graph - Hard - Heap (Priority Queue)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 c... Topics: Graph, Heap (Priority Queue), Shortest Path
- 2012. Process Tasks Using Servers - Medium - Heap (Priority Queue)You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively. servers[i] is the weight of the ith... Topics: Array, Heap (Priority Queue)
- 2023. Design Movie Rental System - Hard - Heap (Priority Queue)You have a movie renting company consisting of n shops. You want to implement a renting system that supports searching for, booking, and returning mov... Topics: Array, Hash Table, Design, Heap (Priority Queue), Ordered Set
- 902. Minimum Number of Refueling Stops - Hard - Heap (Priority Queue)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... Topics: Array, Dynamic Programming, Greedy, Heap (Priority Queue)
- 1990. Get Biggest Three Rhombus Sums in a Grid - Medium - Heap (Priority Queue)You are given an m x n integer matrix grid. A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid. Th... Topics: Array, Math, Sorting, Heap (Priority Queue), Matrix, Prefix Sum
- 264. Ugly Number II - Medium - Heap (Priority Queue)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.... Topics: Hash Table, Math, Dynamic Programming, Heap (Priority Queue)
- 2642. Time to Cross a Bridge - Hard - Heap (Priority Queue)There are k workers who want to move n boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers n and k, and a... Topics: Array, Heap (Priority Queue), Simulation
- 1762. Furthest Building You Can Reach - Medium - Heap (Priority Queue)You are given an integer array heights representing the heights of buildings, some bricks, and some ladders. You start your journey from building 0 an... Topics: Array, Greedy, Heap (Priority Queue)
- 3647. Zero Array Transformation III - Medium - Heap (Priority Queue)You are given an integer array nums of length n and a 2D array queries where queries[i] = [li, ri]. Each queries[i] represents the following action on... Topics: Array, Greedy, Sorting, Heap (Priority Queue), Prefix Sum
- 1953. Finding MK Average - Hard - Heap (Priority Queue)You are given two integers, m and k, and a stream of integers. You are tasked to implement a data structure that calculates the MKAverage for the stre... Topics: Design, Queue, Heap (Priority Queue), Data Stream, Ordered Set
- 3226. Minimum Number Game - Easy - Heap (Priority Queue)You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every ... Topics: Array, Sorting, Heap (Priority Queue), Simulation
- 802. K-th Smallest Prime Fraction - Medium - Heap (Priority Queue)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. Fo... Topics: Array, Two Pointers, Binary Search, Sorting, Heap (Priority Queue)
- 887. Minimum Cost to Hire K Workers - Hard - Heap (Priority Queue)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 wa... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 2436. Make Array Zero by Subtracting Equal Amounts - Easy - Heap (Priority Queue)You are given a non-negative integer array nums. In one operation, you must: Choose a positive integer x such that x is less than or equal to the smal... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Simulation
- 2412. Minimum Amount of Time to Fill Cups - Easy - Heap (Priority Queue)You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or ... Topics: Array, Greedy, Sorting, Heap (Priority Queue)
- 1270. Dinner Plate Stacks - Hard - Heap (Priority Queue)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. Impleme... Topics: Hash Table, Stack, Design, Heap (Priority Queue)
- 1788. Stone Game VI - Medium - Heap (Priority Queue)Alice and Bob take turns playing a game, with Alice starting first. There are n stones in a pile. On each player's turn, they can remove a stone from ... Topics: Array, Math, Greedy, Sorting, Heap (Priority Queue), Game Theory
- 3107. Maximum Spending After Buying Items - Hard - Heap (Priority Queue)You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items wh... Topics: Array, Greedy, Sorting, Heap (Priority Queue), Matrix
- 2164. Two Best Non-Overlapping Events - Medium - Heap (Priority Queue)You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at ... Topics: Array, Binary Search, Dynamic Programming, Sorting, Heap (Priority Queue)
- 1463. The K Weakest Rows in a Matrix - Easy - Heap (Priority Queue)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 ... Topics: Array, Binary Search, Sorting, Heap (Priority Queue), Matrix
- 2329. Maximum Product After K Increments - Medium - Heap (Priority Queue)You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1. R... Topics: Array, Greedy, Heap (Priority Queue)
- 2803. Modify Graph Edge Weights - Hard - Heap (Priority Queue)You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, ... Topics: Graph, Heap (Priority Queue), Shortest Path
- 1286. Constrained Subsequence Sum - Hard - Heap (Priority Queue)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 inte... Topics: Array, Dynamic Programming, Queue, Sliding Window, Heap (Priority Queue), Monotonic Queue
- 2413. Smallest Number in Infinite Set - Medium - Heap (Priority Queue)You have a set which contains all positive integers [1, 2, 3, 4, 5, ...]. Implement the SmallestInfiniteSet class: SmallestInfiniteSet() Initializes t... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
- 2434. Design a Number Container System - Medium - Heap (Priority Queue)Design a number container system that can do the following: Insert or Replace a number at the given index in the system. Return the smallest index for... Topics: Hash Table, Design, Heap (Priority Queue), Ordered Set
- 2423. Minimum Deletions to Make Array Divisible - Hard - Heap (Priority Queue)You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums. Return the minimum number of deletions... Topics: Array, Math, Sorting, Heap (Priority Queue), Number Theory
- 3894. Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values - Medium - Heap (Priority Queue)You are given two integer arrays x and y, each of length n. You must choose three distinct indices i, j, and k such that: x[i] != x[j] x[j] != x[k] x[... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue)
- 3445. Lexicographically Minimum String After Removing Stars - Medium - Heap (Priority Queue)You are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters. While there is a '*', do the followi... Topics: Hash Table, String, Stack, Greedy, Heap (Priority Queue)
- 2300. Construct String With Repeat Limit - Medium - Heap (Priority Queue)You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears ... Topics: Hash Table, String, Greedy, Heap (Priority Queue), Counting
- 2585. Delete Greatest Value in Each Row - Easy - Heap (Priority Queue)You are given an m x n matrix grid consisting of positive integers. Perform the following operation until grid becomes empty: Delete the element with ... Topics: Array, Sorting, Heap (Priority Queue), Matrix, Simulation
- 778. Reorganize String - Medium - Heap (Priority Queue)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... Topics: Hash Table, String, Greedy, Sorting, Heap (Priority Queue), Counting
- 3896. Minimum Time to Transport All Individuals - Hard - Heap (Priority Queue)You are given n individuals at a base camp who need to cross a river to reach a destination using a single boat. The boat can carry at most k people a... Topics: Array, Dynamic Programming, Bit Manipulation, Graph, Heap (Priority Queue), Shortest Path, Bitmask
- 3558. Find a Safe Walk Through a Grid - Medium - Heap (Priority Queue)You are given an m x n binary matrix grid and an integer health. You start on the upper-left corner (0, 0) and would like to get to the lower-right co... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 1325. Path with Maximum Probability - Medium - Heap (Priority Queue)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 connectin... Topics: Array, Graph, Heap (Priority Queue), Shortest Path
- 3610. Find X-Sum of All K-Long Subarrays I - Easy - Heap (Priority Queue)You are given an array nums of n integers and two integers k and x. The x-sum of an array is calculated by the following procedure: Count the occurren... Topics: Array, Hash Table, Sliding Window, Heap (Priority Queue)
- 1464. Reduce Array Size to The Half - Medium - Heap (Priority Queue)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... Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue)
- 675. Cut Off Trees for Golf Event - Hard - Heap (Priority Queue)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 ca... Topics: Array, Breadth-First Search, Heap (Priority Queue), Matrix
- 2553. Total Cost to Hire K Workers - Medium - Heap (Priority Queue)You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker. You are also given two integers k and candidates. W... Topics: Array, Two Pointers, Heap (Priority Queue), Simulation
- 2327. Largest Number After Digit Swaps by Parity - Easy - Heap (Priority Queue)You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits). Return ... Topics: Sorting, Heap (Priority Queue)
- 1479. Construct Target Array With Multiple Sums - Hard - Heap (Priority Queue)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... Topics: Array, Heap (Priority Queue)
- 1489. Pizza With 3n Slices - Hard - Heap (Priority Queue)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... Topics: Array, Dynamic Programming, Greedy, Heap (Priority Queue)
- 2692. Take Gifts From the Richest Pile - Easy - Heap (Priority Queue)You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: Choose the pile with the maxim... Topics: Array, Heap (Priority Queue), Simulation
- 3332. Minimum Operations to Exceed Threshold Value II - Medium - Heap (Priority Queue)You are given a 0-indexed integer array nums, and an integer k. You are allowed to perform some operations on nums, where in a single operation, you c... Topics: Array, Heap (Priority Queue), Simulation
- 2379. Maximum Total Importance of Roads - Medium - Heap (Priority Queue)You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1. You are also given a 2D integer array ... Topics: Greedy, Graph, Sorting, Heap (Priority Queue)
- 2375. Minimum Obstacle Removal to Reach Corner - Hard - Heap (Priority Queue)You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values: 0 represents an empty cell, 1 represents an obstacle t... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 2728. Sum in a Matrix - Medium - Heap (Priority Queue)You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty: From eac... Topics: Array, Sorting, Heap (Priority Queue), Matrix, Simulation
- 2418. Minimum Sum of Squared Difference - Medium - Heap (Priority Queue)You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n. The sum of squared difference of arrays nums1 and nums2 is defi... Topics: Array, Binary Search, Greedy, Sorting, Heap (Priority Queue)
- 1389. Minimum Moves to Move a Box to Their Target Location - Hard - Heap (Priority Queue)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... Topics: Array, Breadth-First Search, Heap (Priority Queue), Matrix
- 2549. Next Greater Element IV - Hard - Heap (Priority Queue)You are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer. The seco... Topics: Array, Binary Search, Stack, Sorting, Heap (Priority Queue), Monotonic Stack
- 3386. Find Edges in Shortest Paths - Hard - Heap (Priority Queue)You are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where e... Topics: Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 3764. Maximum Sum With at Most K Elements - Medium - Heap (Priority Queue)You are given a 2D integer matrix grid of size n x m, an integer array limits of length n, and an integer k. The task is to find the maximum sum of at... Topics: Array, Greedy, Sorting, Heap (Priority Queue), Matrix
- 1612. Avoid Flood in The City - Medium - Heap (Priority Queue)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 wa... Topics: Array, Hash Table, Binary Search, Greedy, Heap (Priority Queue)
- 2543. Most Popular Video Creator - Medium - Heap (Priority Queue)You are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creators[i],... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems