Skip to content
Use code for 50% offSee plans

Heap (Priority Queue) Problems

169 Heap (Priority Queue) LeetCode problems · Solve with AI-powered hints & step-by-step explanations.

Learn the coding interview patterns behind these problems.

Start with these

All Heap (Priority Queue) problems

23 Merge k Sorted Lists Hard215 Kth Largest Element in an Array Medium218 The Skyline Problem Hard239 Sliding Window Maximum Hard264 Ugly Number II Medium295 Find Median from Data Stream Hard347 Top K Frequent Elements Medium355 Design Twitter Medium373 Find K Pairs with Smallest Sums Medium378 Kth Smallest Element in a Sorted Matrix Medium407 Trapping Rain Water II Hard420 Strong Password Checker Hard451 Sort Characters By Frequency Medium480 Sliding Window Median Hard502 IPO Hard506 Relative Ranks Easy621 Task Scheduler Medium630 Course Schedule III Hard632 Smallest Range Covering Elements from K Lists Hard658 Find K Closest Elements Medium659 Split Array into Consecutive Subsequences Medium675 Cut Off Trees for Golf Event Hard692 Top K Frequent Words Medium703 Kth Largest Element in a Stream Easy743 Network Delay Time Medium767 Reorganize String Medium778 Swim in Rising Water Hard786 K-th Smallest Prime Fraction Medium787 Cheapest Flights Within K Stops Medium855 Exam Room Medium857 Minimum Cost to Hire K Workers Hard862 Shortest Subarray with Sum at Least K Hard871 Minimum Number of Refueling Stops Hard882 Reachable Nodes In Subdivided Graph Hard912 Sort an Array Medium973 K Closest Points to Origin Medium1046 Last Stone Weight Easy1054 Distant Barcodes Medium1094 Car Pooling Medium1172 Dinner Plate Stacks Hard1263 Minimum Moves to Move a Box to Their Target Location Hard1268 Search Suggestions System Medium1337 The K Weakest Rows in a Matrix Easy1338 Reduce Array Size to The Half Medium1353 Maximum Number of Events That Can Be Attended Medium1354 Construct Target Array With Multiple Sums Hard1368 Minimum Cost to Make at Least One Valid Path in a Grid Hard1383 Maximum Performance of a Team Hard1388 Pizza With 3n Slices Hard1405 Longest Happy String Medium1424 Diagonal Traverse II Medium1425 Constrained Subsequence Sum Hard1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit Medium1439 Find the Kth Smallest Sum of a Matrix With Sorted Rows Hard1464 Maximum Product of Two Elements in an Array Easy1488 Avoid Flood in The City Medium1499 Max Value of Equation Hard1514 Path with Maximum Probability Medium1606 Find Servers That Handled Most Number of Requests Hard1631 Path With Minimum Effort Medium1642 Furthest Building You Can Reach Medium1648 Sell Diminishing-Valued Colored Balls Medium1675 Minimize Deviation in Array Hard1686 Stone Game VI Medium1687 Delivering Boxes from Storage to Ports Hard1696 Jump Game VI Medium1705 Maximum Number of Eaten Apples Medium1738 Find Kth Largest XOR Coordinate Value Medium1753 Maximum Score From Removing Stones Medium1776 Car Fleet II Hard1786 Number of Restricted Paths From First to Last Node Medium1792 Maximum Average Pass Ratio Medium1801 Number of Orders in the Backlog Medium1825 Finding MK Average Hard1834 Single-Threaded CPU Medium1845 Seat Reservation Manager Medium1851 Minimum Interval to Include Each Query Hard1878 Get Biggest Three Rhombus Sums in a Grid Medium1882 Process Tasks Using Servers Medium1912 Design Movie Rental System Hard1942 The Number of the Smallest Unoccupied Chair Medium1962 Remove Stones to Minimize the Total Medium1985 Find the Kth Largest Integer in the Array Medium2034 Stock Price Fluctuation Medium2054 Two Best Non-Overlapping Events Medium2099 Find Subsequence of Length K With the Largest Sum Easy2102 Sequentially Ordinal Rank Tracker Hard2146 K Highest Ranked Items Within a Price Range Medium2163 Minimum Difference in Sums After Removal of Elements Hard2182 Construct String With Repeat Limit Medium2208 Minimum Operations to Halve Array Sum Medium2231 Largest Number After Digit Swaps by Parity Easy2233 Maximum Product After K Increments Medium2285 Maximum Total Importance of Roads Medium2290 Minimum Obstacle Removal to Reach Corner Hard2333 Minimum Sum of Squared Difference Medium2335 Minimum Amount of Time to Fill Cups Easy2336 Smallest Number in Infinite Set Medium2342 Max Sum of a Pair With Equal Sum of Digits Medium2343 Query Kth Smallest Trimmed Number Medium2344 Minimum Deletions to Make Array Divisible Hard2349 Design a Number Container System Medium2353 Design a Food Rating System Medium2357 Make Array Zero by Subtracting Equal Amounts Easy2386 Find the K-Sum of an Array Hard2398 Maximum Number of Robots Within Budget Hard2402 Meeting Rooms III Hard2406 Divide Intervals Into Minimum Number of Groups Medium2424 Longest Uploaded Prefix Medium2454 Next Greater Element IV Hard2456 Most Popular Video Creator Medium2462 Total Cost to Hire K Workers Medium2497 Maximum Star Sum of a Graph Medium2500 Delete Greatest Value in Each Row Easy2503 Maximum Number of Points From Grid Queries Hard2512 Reward Top K Students Medium2530 Maximal Score After Applying K Operations Medium2532 Time to Cross a Bridge Hard2542 Maximum Subsequence Score Medium2551 Put Marbles in Bags Hard2558 Take Gifts From the Richest Pile Easy2577 Minimum Time to Visit a Cell In a Grid Hard2593 Find Score of an Array After Marking All Elements Medium2611 Mice and Cheese Medium2617 Minimum Number of Visited Cells in a Grid Hard2642 Design Graph With Shortest Path Calculator Hard2662 Minimum Cost of a Path With Special Roads Medium2679 Sum in a Matrix Medium2699 Modify Graph Edge Weights Hard2762 Continuous Subarrays Medium2812 Find the Safest Path in a Grid Medium2813 Maximum Elegance of a K-Length Subsequence Hard2931 Maximum Spending After Buying Items Hard2940 Find Building Where Alice and Bob Can Meet Hard2944 Minimum Number of Coins for Fruits Medium2959 Number of Possible Sets of Closing Branches Hard2973 Find Number of Coins to Place in Tree Nodes Hard2974 Minimum Number Game Easy3013 Divide an Array Into Subarrays With Minimum Cost II Hard3049 Earliest Second to Mark Indices II Hard3066 Minimum Operations to Exceed Threshold Value II Medium3080 Mark Elements on Array by Performing Queries Medium3081 Replace Question Marks in String to Minimize Its Value Medium3092 Most Frequent IDs Medium3112 Minimum Time to Visit Disappearing Nodes Medium3123 Find Edges in Shortest Paths Hard3170 Lexicographically Minimum String After Removing Stars Medium3264 Final Array State After K Multiplication Operations I Easy3266 Final Array State After K Multiplication Operations II Hard3275 K-th Nearest Obstacle Queries Medium3286 Find a Safe Walk Through a Grid Medium3296 Minimum Number of Seconds to Make Mountain Height Zero Medium3318 Find X-Sum of All K-Long Subarrays I Easy3321 Find X-Sum of All K-Long Subarrays II Hard3341 Find Minimum Time to Reach Last Room I Medium3342 Find Minimum Time to Reach Last Room II Medium3362 Zero Array Transformation III Medium3377 Digit Operations to Make Two Integers Equal Medium3408 Design Task Manager Medium3462 Maximum Sum With at Most K Elements Medium3478 Choose K Elements With Maximum Sum Medium3505 Minimum Operations to Make Elements Within K Subarrays Equal Hard3507 Minimum Pair Removal to Sort Array I Easy3510 Minimum Pair Removal to Sort Array II Hard3572 Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values Medium3594 Minimum Time to Transport All Individuals Hard3604 Minimum Time to Reach Destination in Directed Graph Medium3607 Power Grid Maintenance Medium3620 Network Recovery Pathways Hard