Heap
Heap
Forty-five questions on heaps and priority queues, for efficiently tracking the smallest or largest elements in a stream.
Delete Greatest Value in Each Row
easyYou are given an m x n matrix grid consisting of positive integers.
Final Array State After K Multiplication Operations I
easyYou are given an integer array nums, an integer k, and an integer multiplier.
Find Subsequence of Length K With the Largest Sum
easyYou are given an integer array nums and an integer k.
Find X-Sum of All K-Long Subarrays I
easyYou are given an array nums of n integers and two integers k and x.
Largest Number After Digit Swaps by Parity
easyYou are given a positive integer num.
Last Stone Weight
easyYou are given an array of integers stones where stones[i] is the weight of the ith stone.
Make Array Zero by Subtracting Equal Amounts
easyYou are given a non-negative integer array nums.
Minimum Amount of Time to Fill Cups
easyYou have a water dispenser that can dispense cold, warm, and hot water.
Minimum Number Game
easyYou are given a 0-indexed integer array nums of even length and there is also an empty array arr.
Minimum Pair Removal to Sort Array I
easyGiven an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.
Relative Ranks
easyYou are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition.
Take Gifts From the Richest Pile
easyYou are given an integer array gifts denoting the number of gifts in various piles.
Avoid Flood in The City
mediumYour country has an infinite number of lakes.
Car Pooling
mediumThere is a car with capacity empty seats.
Cheapest Flights Within K Stops
mediumThere are n cities connected by some number of flights.
Choose K Elements With Maximum Sum
mediumYou are given two integer arrays, nums1 and nums2, both of length n, along with a positive integer k.
Construct String With Repeat Limit
mediumYou are given a string s and an integer repeatLimit.
Continuous Subarrays
mediumYou are given a 0-indexed integer array nums.
Diagonal Traverse II
mediumGiven a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.
Digit Operations to Make Two Integers Equal
mediumYou are given two integers n and m that consist of the same number of digits.
Distant Barcodes
mediumIn a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i].
Divide Intervals Into Minimum Number of Groups
mediumYou are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti].
Find a Safe Walk Through a Grid
mediumYou are given an m x n binary matrix grid and an integer health.
Find K Closest Elements
mediumGiven a sorted integer array arr, two integers k and x, return the k closest integers to x in the array.
Find K Pairs with Smallest Sums
mediumYou are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k.
Find Kth Largest XOR Coordinate Value
mediumYou are given a 2D matrix of size m x n, consisting of non-negative integers.
Find Minimum Time to Reach Last Room I
mediumThere is a dungeon with n x m rooms arranged as a grid.
Find Minimum Time to Reach Last Room II
mediumThere is a dungeon with n x m rooms arranged as a grid.
Find Score of an Array After Marking All Elements
mediumYou are given an array nums consisting of positive integers.
Find the Kth Largest Integer in the Array
mediumYou are given an array of strings nums and an integer k.
Find the Safest Path in a Grid
mediumYou are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents: You are initially positioned at cell (0, 0).
Furthest Building You Can Reach
mediumYou are given an integer array heights representing the heights of buildings, some bricks, and some ladders.
Get Biggest Three Rhombus Sums in a Grid
mediumYou are given an m x n integer matrix grid.
Jump Game VI
mediumYou are given a 0-indexed integer array nums and an integer k.
K Closest Points to Origin
mediumGiven 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).
K Highest Ranked Items Within a Price Range
mediumYou are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop.
K-th Nearest Obstacle Queries
mediumThere is an infinite 2D plane.
K-th Smallest Prime Fraction
mediumYou are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique.
Kth Largest Element in an Array
mediumGiven an integer array nums and an integer k, return the kth largest element in the array.
Kth Smallest Element in a Sorted Matrix
mediumGiven 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.
Lexicographically Minimum String After Removing Stars
mediumYou are given a string s.
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
mediumGiven 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 two elements of this subarray...
Longest Happy String
mediumA string s is called happy if it satisfies the following conditions: Given three integers a, b, and c, return the longest possible happy string.
Mark Elements on Array by Performing Queries
mediumYou are given a 0-indexed array nums of size n consisting of positive integers.
Max Sum of a Pair With Equal Sum of Digits
mediumYou are given a 0-indexed array nums consisting of positive integers.