Topic
Heaps, Sorting & Search interview problems
Priority queues, binary search and custom ordering. 200 original problems, each with hidden test cases you can run in the browser.
24 easy163 medium13 hard
Showing 1–30 of 200 results
Count element-level comparisons during an adaptive divide-and-conquer merge sort.
Auto-gradedsortingdivide-and-conquerrecursionarraysCompute 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.
Auto-gradedsliding-windowfenwick-treeorder-statisticsheapsRank teams with a multi-level tiebreak (points, goal difference, goals scored, index) and return the best two indices, testing composite keys and efficient selection.
Auto-gradedsortingtuple-keystie-breakingselectionLocate a local minimum in an array of integers in logarithmic time while handling flat regions and boundaries.
Model answerarraysbinary-searchalgorithmsDesign a data structure that accepts an array of positive item weights and samples indices proportional to their relative weight values.
Model answerbinary searchprefix sumrandom samplingdesign-dsSimulate repeatedly removing the two largest values and reinserting their difference, using a max-heap to find the last remaining value or 0.
Auto-gradedheappriority-queuesimulationPerform logarithmic-time binary search on a strictly increasing array of distinct integers to find a target value's index or detect its absence.
Auto-gradedbinary-searcharrayssearchingReturn 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.
Model answersliding-windowheapmedianlazy-deletionSolve 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.
Model answerheapgreedylinked-liststringSimulate 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.
Model answerheapsimulationpriority-queueintervalsCount 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.
Model answerword-countstreamingexternal-memorytop-kUse 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.
Auto-gradedbinary-searchsorted-arrayboundariesMerge 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.
Auto-gradedheapk-way-mergedivide-and-conquersortingSimulate 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.
Auto-gradedheapgreedysimulationpriority-queueSort 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.
Auto-gradedbinary-searchsortinginterpolationgeometryApply a quadratic mapping to a sorted list of numbers and return the sorted results in O(n) time.
Auto-gradedtwo-pointersarraysmathFind 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.
Auto-gradedsortingcountingh-indexarraysSort a probability list with deterministic tie-breaking, then build two truncated, renormalized versions: fixed-size top-k and cumulative-mass top-p.
Auto-gradedsortingprefix-sumprobabilityfloating-pointSearch 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.
Auto-gradedbinary-searcharraysrotated-arraydivide-and-conquerSort 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.
Auto-gradedsortingdivide-and-conquermerge-sortstabilityCombines 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.
Auto-gradedheapsliding-windowtwo-pointersorder-statisticsFind all distinct combinations of three elements in an integer sequence that sum to zero using two pointers and duplicate handling.
Auto-gradedarraystwo-pointerssortingFind the smallest semantic version that satisfies a monotonic compatibility check while minimizing evaluations.
Auto-gradedbinary-searchsortingarraysSelect 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.
Auto-gradedbinary-searchhash-mapsortingsliding-windowFind 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.
Auto-gradedquickselectselectionpartitioningorder-statisticsCompute the mean of every fixed-size window after removing its k largest entries, which requires an ordered structure that supports efficient insertion and deletion.
Auto-gradedsliding-windowheapfenwick-treeorder-statisticsEvaluate efficient sorted array lookups for repetitive queries using binary search combined with memoization.
Auto-gradedbinary-searcharraysmemoizationhashingEvaluate 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.
Auto-gradedbinary-searchinterpolationarraysedge-casesFind 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.
Auto-gradedbinary-searchrotated-arrayhash-mapfrequency-countEnumerate 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.
Auto-gradedsortingpair-enumerationgeometrymulti-key-sort