KatInterview

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.

Problems200

24 easy163 medium13 hard

Showing 121–150 of 200 results

  • Replay a shuffled log of credit grants, spends and balance queries in time order, spending the soonest-expiring credits first, using a heap and sorting.

    Auto-gradedheapsortingsimulationoffline-processing
  • Maintain the median of a growing sequence after each new value arrives, testing efficient order-statistic upkeep with a pair of heaps.

    Auto-gradedheaptwo-heapsstreamingmedian
  • Find the k-th largest value in an unsorted integer list, counting duplicates separately, without necessarily sorting the whole list.

    Auto-gradedheapquickselectselectionarrays
  • Place a depot on a 2D integer grid to minimize total Manhattan distance to all warehouses, avoiding any cell occupied by an obstacle.

    Model answermanhattan-distancemedianpriority-queueprefix-sums
  • Find one conflicting pair among n items using a black-box oracle that tests subsets, minimizing the number of expensive queries.

    Model answerbinary-searchoptimizationoracleinformation-theory
  • Tests binary search on window positions with careful tie-breaking that prefers smaller values when distances are equal.

    Auto-gradedbinary-searchsliding-windowtwo-pointers
  • Tests prefix sums and binary search to map ticket numbers into population-weighted ranges efficiently.

    Auto-gradedbinary-searchprefix-sumsarrays
  • Tests binary search on sorted arrays with duplicates to answer multiple inclusive range queries in O(log n) per query.

    Auto-gradedbinary-searcharraystwo-pointers
  • Tests implementation of quickselect to find the k-th largest value in an unsorted array, treating duplicates as separate elements.

    Auto-gradedquickselectpartitioningselection-algorithms
  • Find the smallest valid ordering of numbered items when some must precede others, or detect when circular dependencies make ordering impossible.

    Auto-gradedtopological-sortgraphheapgreedy
  • Tests k-way merging of pre-sorted sequences using a min-heap, deterministic tie-breaking by source index, and accumulating a running total across all events.

    Auto-gradedheapmergek-way-mergerunning-sum
  • Tests efficient multi-way merge using a min-heap to extract the k smallest values from multiple sorted arrays without flattening the entire input.

    Auto-gradedheapmergesortingoptimization
  • Find the max and min sliding-window medians in O(n log k), then partition a binary array into even uniform segments with minimum flips.

    Model answersliding windowheapdynamic programmingbinary array
  • Tests sorting and greedy scanning to identify the smallest gap between elements and extract all pairs achieving it.

    Auto-gradedsortinggreedyarrays
  • Tests the ability to partition an array into three distinct categories using a single-pass, constant-space algorithm.

    Auto-gradedarraystwo-pointerssortingpartitioning
  • Tests simulation using a priority queue with lazy deletion and a linked list to repeatedly remove the smallest remaining element and its current neighbors.

    Auto-gradedheaplinked-listsimulationlazy-deletion
  • Tests whether a candidate can isolate records by category and then apply binary search to efficiently locate all entries within an inclusive date window.

    Auto-gradedbinary-searchsortingdata-manipulation
  • Tests whether a candidate can recognize a monotonic predicate and apply binary search to find the first transition point without comparing version strings.

    Auto-gradedbinary-searcharraysmonotonic-predicate
  • Tests whether a candidate can run a single-pass binary search on a sorted array that has been cyclically shifted by an unknown offset.

    Auto-gradedbinary-searcharraysdivide-and-conquer
  • Tests binary search on value space combined with an O(n) staircase count to efficiently locate the k-th smallest element in a doubly sorted matrix.

    Auto-gradedbinary-searchmatrixheap
  • Tests greedy optimization with category constraints, hash-map aggregation, and heap-based top-k selection.

    Auto-gradedgreedyhashmapheapoptimization
  • Tests ability to compute per-group medians over a list of records, correctly handling odd/even counts, duplicate values, and half-up rounding to two decimal places.

    Auto-gradedsortinggroupingmediandecimal-precision
  • Tests frequency counting and top-k selection using hash maps, heaps, or bucket sort, including complexity trade-off reasoning.

    Auto-gradedhash-mapheapbucket-sort
  • Tests threshold search on a scored ranking: find the cut-point that maximises recall while keeping precision at or above a given floor, with correct tie-breaking.

    Auto-gradedsortingprecision-recallbinary-classification
  • Count unique values in a sorted array by jumping between runs using binary search, achieving sublinear time when diversity is low.

    Auto-gradedbinary-searcharrayssorted-arrayoptimization
  • Simulate dispatching sequential tasks to parallel workers and determine when all work completes.

    Auto-gradedheapsimulationgreedy
  • Implement sublinear algorithms to identify a local minimum in a 1D array and a 2D grid by applying binary search to unimodal descent.

    Model answerbinary-searchdivide-and-conqueralgorithms
  • Tests frequency counting and compound-key sorting to find the k most common strings, resolving ties by alphabetical order for both ranking and inclusion.

    Auto-gradedsortinghash-mapheap
  • Sort an array, find the smallest difference between adjacent elements, and count how many consecutive pairs share that difference.

    Auto-gradedarrayssortingcounting
  • Tests pairwise distance computation with a missing-data-aware MSE metric, tie-breaking, and top-K ranking across user profiles.

    Auto-gradedsortingsimilaritymissing-data

More topics