practice a little every day — you've got this ♡
Heaps, Sorting & Search Interview Problems
Practice 5967 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.
- 5967
- Problems
- 2210
- Auto-graded
- 15
- Topics
- 272
- Added today
Showing 1–30 of 200 results
- Heaps, Sorting & SearchEasyAuto-gradedAdaptive Merge Sort with Comparison Counter
Count element-level comparisons during an adaptive divide-and-conquer merge sort.
Heaps, Sorting & Searchsortingdivide-and-conquerrecursionarrays - Heaps, Sorting & SearchMediumAuto-gradedRolling Window Mean After Dropping the Largest k
Compute the mean of each fixed-size window after discarding its k largest values, which needs a structure that supports fast insertion, deletion and sum-of-smallest queries.
Heaps, Sorting & Searchsliding-windowfenwick-treeorder-statisticsheaps - Heaps, Sorting & SearchMediumAuto-gradedPodium Finish: Pick the Two Best Clubs in a League Table
Rank teams with a multi-level tiebreak (points, goal difference, goals scored, index) and return the best two indices, testing composite keys and efficient selection.
Heaps, Sorting & Searchsortingtuple-keystie-breakingselection - Heaps, Sorting & SearchMediumModel answerFind Index of Local Minimum Using Binary Search
Locate a local minimum in an array of integers in logarithmic time while handling flat regions and boundaries.
Heaps, Sorting & Searcharraysbinary-searchalgorithms - Heaps, Sorting & SearchMediumModel answerImplement Weighted Index Selector with Efficient Retrieval
Design a data structure that accepts an array of positive item weights and samples indices proportional to their relative weight values.
Heaps, Sorting & Searchbinary searchprefix sumrandom samplingdesign-ds - Heaps, Sorting & SearchEasyAuto-gradedLast Stone Standing: Repeated Smash of the Two Heaviest Weights
Simulate repeatedly removing the two largest values and reinserting their difference, using a max-heap to find the last remaining value or 0.
Heaps, Sorting & Searchheappriority-queuesimulation - Heaps, Sorting & SearchEasyAuto-gradedLocate Element in Sorted Array
Perform logarithmic-time binary search on a strictly increasing array of distinct integers to find a target value's index or detect its absence.
Heaps, Sorting & Searchbinary-searcharrayssearching - Heaps, Sorting & SearchMediumModel answerRolling Window Medians with Two Heaps and Lazy Removal
Return the median of every length-k window of an integer array in O(n log k) time, handling duplicates, removals of departing elements, and the even-k convention.
Heaps, Sorting & Searchsliding-windowheapmedianlazy-deletion - Heaps, Sorting & SearchMediumModel answerThree Classics: Spaced Characters, Merged Streams, Cloned Lists
Solve three linked tasks: rearrange a string so no neighbors match, merge k sorted linked lists, and deep-copy a linked list whose nodes carry an extra arbitrary pointer.
Heaps, Sorting & Searchheapgreedylinked-liststring - Heaps, Sorting & SearchMediumModel answerAssign Meetings to Rooms and Find the Most-Used One
Simulate meetings being placed into n numbered rooms, delaying them when all rooms are full, then report the room that hosted the most meetings, preferring the lowest index on ties.
Heaps, Sorting & Searchheapsimulationpriority-queueintervals - Heaps, Sorting & SearchMediumModel answerTop Words in a Huge Text File Under Tight Memory
Count word frequencies in a text file far larger than RAM, with explicit tokenization rules and an efficient exact top-K, and analyze time, memory and disk costs.
Heaps, Sorting & Searchword-countstreamingexternal-memorytop-k - Heaps, Sorting & SearchEasyAuto-gradedLocate the Span of a Value in a Sorted List
Use binary search to find the first and last positions of a value in a sorted list in logarithmic time, returning [-1, -1] when it is absent.
Heaps, Sorting & Searchbinary-searchsorted-arrayboundaries - Heaps, Sorting & SearchMediumAuto-gradedCombine Several Ascending Sequences into One Sorted Sequence
Merge k individually sorted integer arrays into a single sorted array, testing heap-based k-way merging or pairwise divide-and-conquer and the associated complexity analysis.
Heaps, Sorting & Searchheapk-way-mergedivide-and-conquersorting - Heaps, Sorting & SearchMediumAuto-gradedGreedy Tile Placement Across Parallel Lanes
Simulate placing items one by one into the currently lowest lane, breaking ties by lowest index, and report each lane's final total using a min-heap.
Heaps, Sorting & Searchheapgreedysimulationpriority-queue - Heaps, Sorting & SearchMediumAuto-gradedEvaluate a Broken-Line Curve at a Query Position
Sort scattered points by x, then find the y on the connecting line at a query x, interpolating inside the range and extending the end segments outside it.
Heaps, Sorting & Searchbinary-searchsortinginterpolationgeometry - Heaps, Sorting & SearchMediumAuto-gradedOrder Transformed Values of a Sorted Array
Apply a quadratic mapping to a sorted list of numbers and return the sorted results in O(n) time.
Heaps, Sorting & Searchtwo-pointersarraysmath - Heaps, Sorting & SearchMediumAuto-gradedLargest Threshold Met by Daily Step Counts
Find the largest integer k such that at least k entries in a list are at least k, testing sorting or counting-based selection and reasoning about monotone thresholds.
Heaps, Sorting & Searchsortingcountingh-indexarrays - Heaps, Sorting & SearchMediumAuto-gradedTruncate and Renormalize a Next-Token Distribution
Sort a probability list with deterministic tie-breaking, then build two truncated, renormalized versions: fixed-size top-k and cumulative-mass top-p.
Heaps, Sorting & Searchsortingprefix-sumprobabilityfloating-point - Heaps, Sorting & SearchMediumAuto-gradedLocate a Value in a Cyclically Shifted Ascending List
Search a cyclically shifted strictly increasing list of distinct integers for a value in O(log n), returning its index or -1, including unshifted and single-element cases.
Heaps, Sorting & Searchbinary-searcharraysrotated-arraydivide-and-conquer - Heaps, Sorting & SearchMediumAuto-gradedStable Divide-and-Conquer Sort of an Integer List
Sort a list of integers in ascending order without mutating the input, using a divide-and-conquer merge approach that guarantees O(n log n) time and linear auxiliary space.
Heaps, Sorting & Searchsortingdivide-and-conquermerge-sortstability - Heaps, Sorting & SearchMediumAuto-gradedRank Selection Plus Longest Leave-Assisted Break
Combines selecting the element at a 0-indexed rank in descending order with a sliding window finding the longest stretch containing at most a given number of workdays.
Heaps, Sorting & Searchheapsliding-windowtwo-pointersorder-statistics - Heaps, Sorting & SearchMediumAuto-gradedIdentify Unique Zero-Sum Triples
Find all distinct combinations of three elements in an integer sequence that sum to zero using two pointers and duplicate handling.
Heaps, Sorting & Searcharraystwo-pointerssorting - Heaps, Sorting & SearchMediumAuto-gradedFind Earliest Compatible Release Version
Find the smallest semantic version that satisfies a monotonic compatibility check while minimizing evaluations.
Heaps, Sorting & Searchbinary-searchsortingarrays - Heaps, Sorting & SearchMediumAuto-gradedMost Frequent Ads Within a Closed Time Range
Select the K most frequent ad IDs among timestamped impressions in an inclusive window, breaking ties by smaller ID; tests binary search on sorted data plus counting and ordering.
Heaps, Sorting & Searchbinary-searchhash-mapsortingsliding-window - Heaps, Sorting & SearchMediumAuto-gradedPick the k-th Smallest Value Without Fully Sorting
Find the k-th smallest value in an unsorted integer list, counting duplicates, using a linear-time selection idea such as quickselect instead of a full sort.
Heaps, Sorting & Searchquickselectselectionpartitioningorder-statistics - Heaps, Sorting & SearchMediumAuto-gradedWindow Mean After Discarding the Top Values
Compute the mean of every fixed-size window after removing its k largest entries, which requires an ordered structure that supports efficient insertion and deletion.
Heaps, Sorting & Searchsliding-windowheapfenwick-treeorder-statistics - Heaps, Sorting & SearchMediumAuto-gradedBatched Binary Search with Query Caching
Evaluate efficient sorted array lookups for repetitive queries using binary search combined with memoization.
Heaps, Sorting & Searchbinary-searcharraysmemoizationhashing - Heaps, Sorting & SearchMediumAuto-gradedRead a Value Off a Connected Line-Segment Graph
Evaluate a piecewise linear curve at a query coordinate by locating the right segment with binary search and interpolating, returning None outside the curve's domain.
Heaps, Sorting & Searchbinary-searchinterpolationarraysedge-cases - Heaps, Sorting & SearchMediumAuto-gradedRotated Array Lookup Plus Most Common Values
Find a value's index in a rotated sorted array with binary search, then list the k most frequent values with ties broken by smaller value.
Heaps, Sorting & Searchbinary-searchrotated-arrayhash-mapfrequency-count - Heaps, Sorting & SearchMediumAuto-gradedRank Point Pairs by Bounding Hyperrectangle Volume
Enumerate point pairs in d dimensions, compute the volume of the box they span, drop flat boxes, and return the rest in a strict multi-key order.
Heaps, Sorting & Searchsortingpair-enumerationgeometrymulti-key-sort