KatInterview

practice a little every day — you've got this ♡

Heaps, Sorting & Search Interview Problems

Practice 5971 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.

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 91–120 of 200 results

  • Heaps, Sorting & SearchMediumAuto-graded
    Bidirectional Bubble Sort with Early Exit and Shrinking Window

    Implement a two-direction adjacent-swap sort that returns a new sorted list, using window shrinking and early termination, while reasoning about its cost.

    Heaps, Sorting & Searchsortingtwo-pointersbubble-sortin-place
  • Heaps, Sorting & SearchMediumAuto-graded
    Lowest-Numbered Free Room Booking for Time Slots

    Simulate a deterministic room-allocation process with heaps: sort by start, free finished rooms, pick the smallest free ID, and report assignments in input order.

    Heaps, Sorting & Searchheapsimulationsortingintervals
  • Heaps, Sorting & SearchMediumAuto-graded
    Where Is Everyone? Locating Travelers at a Given Instant

    Group unsorted flight records by traveler and decide each traveler's status at a query timestamp, using half-open flight intervals.

    Heaps, Sorting & Searchsortinghash-mapintervalstimestamps
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate K Nearest Values in a Sorted Sequence

    Binary search for the starting boundary of a contiguous k-element slice minimizing distance to a given target in a sorted list.

    Heaps, Sorting & Searchbinary-searchtwo-pointersarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Maximize Resource Harvest with Linear Depletion

    Find the maximum yield from extracting resources over K time steps when each extraction reduces a site's yield by 1 using binary search on the minimum threshold.

    Heaps, Sorting & Searcharraysheaps-sortinggreedy-intervalsmath-bits
  • Heaps, Sorting & SearchMediumAuto-graded
    Merge Multiple Sorted Series with Grouping

    Efficiently merge K pre-sorted event logs while combining entries sharing identical timestamps.

    Heaps, Sorting & Searchheaps-sortingarraystwo-pointers
  • Heaps, Sorting & SearchMediumModel answer
    Minimize Black-Box Unimodal Function Without Derivatives

    Find the minimum of a convex/unimodal function over continuous and discrete intervals using zero-order optimization.

    Heaps, Sorting & Searchbinary searchoptimizationunimodalgolden section
  • Heaps, Sorting & SearchMediumAuto-graded
    Where Is the Traveler? Locate by Timestamp from Trip Logs

    Answer timestamp queries against unsorted trip intervals using sorting and binary search, handling closed boundaries, gaps between trips, and times before the first trip.

    Heaps, Sorting & Searchbinary-searchsortingintervalssimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Select the k Most Common Values with Tie Rules

    Count value frequencies and pick the k most frequent values, using a bounded heap and a defined tie-break rule for equal counts.

    Heaps, Sorting & Searchheaphash-mapfrequency-countingtop-k
  • Heaps, Sorting & SearchEasyAuto-graded
    Adjacent Entries Lookup in a Sorted Catalog

    Answer batched queries on a sorted list of unique IDs by binary searching for each target and returning its adjacent values, or nulls when the target is absent.

    Heaps, Sorting & Searchbinary-searchsorted-arraybisectbatch-queries
  • Heaps, Sorting & SearchEasyAuto-graded
    Locate Gap in Sorted Consecutive Sequence

    Detect a missing entry in a sorted contiguous array of integers in logarithmic time using binary search.

    Heaps, Sorting & Searcharraysbinary-search
  • Heaps, Sorting & SearchEasyAuto-graded
    Rank Top Earners Worldwide After Converting to USD

    Merge several lists of employee records, convert each salary to USD using a rate map, and return the top N earners with a deterministic tie-break.

    Heaps, Sorting & Searchsortinghash-mapdata-manipulationsimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Valley Finder: Binary Search on an Unsorted Zigzag Array

    Find a valley index in an array of adjacent-distinct integers in logarithmic time, using a fixed halving rule that makes the returned index deterministic.

    Heaps, Sorting & Searchbinary-searcharraysinvariantsiterative
  • Heaps, Sorting & SearchMediumAuto-graded
    Resume a Sorted Score Listing from a Last-Seen Key

    Filter records by a minimum score, order them by score then id, and return one page after a (score, id) cursor along with the cursor for the following page.

    Heaps, Sorting & Searchpaginationsortingtuple-comparisonheap
  • Heaps, Sorting & SearchMediumAuto-graded
    Running Median Over a Command Log of Inserts and Queries

    Process a log of insert and query commands on a growing multiset of integers, reporting the median at each query using two heaps for efficient updates.

    Heaps, Sorting & Searchheaptwo-heapsstreamingmedian
  • Heaps, Sorting & SearchEasyAuto-graded
    Rank Advertisers by Reports, Then Report Rate

    Aggregate per-ad records by advertiser, then rank with a multi-key sort (total reports, report rate, id) and return the top k.

    Heaps, Sorting & Searchhashingsortingaggregationcustom-sort-key
  • Heaps, Sorting & SearchMediumAuto-graded
    Replay Commands to Track a Running Median

    Replay a list of insert and query commands on a growing multiset of integers, reporting the median at each query; tests two-heap or order-statistic maintenance.

    Heaps, Sorting & Searchheapstreamingmediandesign
  • Heaps, Sorting & SearchEasyAuto-graded
    Closest Points to a Query Vector, Ranked with Index Tie-Break

    Select the k dataset points nearest to a query in n-dimensional space, ordered by distance, with ties resolved by smaller index.

    Heaps, Sorting & Searchk-nearest-neighborssortingheapeuclidean-distance
  • Heaps, Sorting & SearchMediumAuto-graded
    Leftmost Match in a Sorted Sequence Without a Known Size

    Find the first index of a target in a sorted list while the search pretends its length is unknown, using doubling probes followed by a lower-bound binary search.

    Heaps, Sorting & Searchbinary-searchexponential-searchduplicatessorted-array
  • Heaps, Sorting & SearchEasyAuto-graded
    Clean, Impute and Rank Student Score Records

    Filter records with too many missing values, fill gaps with per-subject medians, then pick the top five using a multi-key sort with tie-breaks.

    Heaps, Sorting & Searchsortingmediandata-cleaningsimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Gini Split Search Plus One Regression Gradient Step

    Sweep sorted feature values to find the lowest weighted-Gini binary split, and apply one MSE gradient descent update for linear regression.

    Heaps, Sorting & Searchsortingprefix-sweepgini-impuritygradient-descent
  • Heaps, Sorting & SearchMediumModel answer
    Streaming Word Frequencies from an Oversized Text File

    Build a memory-safe word counter for a huge text file, define tokenization rules, return the top-k words deterministically, and discuss what to do when the vocabulary strains memory.

    Heaps, Sorting & Searchword-countstreaminghash-maptop-k
  • Heaps, Sorting & SearchHardAuto-graded
    Pick the Bottle Kit With the Least Leftover Volume

    Choose the bottle kit that serves every dose request with minimal total leftover space, using sorting, prefix sums and binary search to stay efficient on large inputs.

    Heaps, Sorting & Searchbinary-searchprefix-sumssortinggreedy
  • Heaps, Sorting & SearchMediumAuto-graded
    Rank Anti-Diagonal Strings of a Letter Grid

    Build a string for each anti-diagonal of a letter grid, read bottom-left to top-right, and return diagonal indices ordered by string, with ties broken by index.

    Heaps, Sorting & Searchmatrixsortingstringstie-breaking
  • Heaps, Sorting & SearchMediumModel answer
    Batched Notification Sender with Cooldown-Aware Retries

    Push messages through a provider that accepts at most 5 per call, and retry each failure only after its own cooldown expires, with an attempt cap and no busy-waiting.

    Heaps, Sorting & Searchbatchingpriority-queueretry-schedulingmin-heap
  • Heaps, Sorting & SearchMediumModel answer
    Cost of Core Data Structure Ops and When Threads Hurt

    Give worst-case Big-O for four common array, hash table and heap operations, then explain why adding threads does not always speed a program up, with concrete counterexamples.

    Heaps, Sorting & Searchbig-ohash-tableheapmultithreading
  • Heaps, Sorting & SearchMediumModel answer
    Fixed-Width Window Totals and Rolling Median Over a Stream

    Find the best sum over any run of k adjacent numbers, then track the median of the latest k values in a live stream, discussing data structures, parallelism and trade-offs.

    Heaps, Sorting & Searchsliding-windowtwo-heapsmedianlazy-deletion
  • Heaps, Sorting & SearchMediumAuto-graded
    Cheapest Full Merge and Matching-Sum Product Total

    Combine a Huffman-style min-heap greedy for the cheapest full merge with a frequency-map count of index pairs hitting a target sum, summing their products.

    Heaps, Sorting & Searchheapgreedyhash-mapcounting
  • Heaps, Sorting & SearchMediumAuto-graded
    One-Car Sweep Scheduler: Order the Elevator Stops

    Order a single elevator's pending floor requests using a one-reversal sweep policy with a priority queue, merging duplicates and respecting the starting direction.

    Heaps, Sorting & Searchheappriority-queuesortingsimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    First Index at Least Target in a Padded Sorted Stream

    Find the first index with value at least the target in a sorted sequence of hidden length, using doubling probes followed by binary search.

    Heaps, Sorting & Searchbinary-searchexponential-searchsorted-arrayinvariants