KatInterview

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

Heaps, Sorting & Search Interview Problems

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

5966
Problems
2209
Auto-graded
15
Topics
271
Added today

Showing 31–60 of 200 results

  • Heaps, Sorting & SearchMediumModel answer
    Ordering a Hundred Million Decimal Digits in Place

    Order a huge byte array holding only the values 0 to 9 in linear time with constant extra memory, then reason about storage layout, memory bandwidth and expected runtime.

    Heaps, Sorting & Searchcounting-sortin-placememory-bandwidthbytearray
  • Heaps, Sorting & SearchMediumAuto-graded
    Build a Max-Heap In Place with Bottom-Up Sifting

    Convert an integer list into a max-heap layout using the bottom-up sift-down procedure, matching an exact output array including tie-break behavior.

    Heaps, Sorting & Searchheaparraysift-downin-place
  • Heaps, Sorting & SearchEasyAuto-graded
    Permutation Search Sort: Order a List by Brute Force

    Implement a factorial-time sort that tries arrangements until one is non-decreasing, handling duplicates and empty input, and reason about its cost.

    Heaps, Sorting & Searchsortingpermutationsbrute-forcecomplexity-analysis
  • Heaps, Sorting & SearchEasyAuto-graded
    Impute Missing Grades and Rank Top Candidates

    Process raw assessment records by replacing missing marks with course-level medians and return the top 5 performers.

    Heaps, Sorting & Searchsortingdata-cleaninghash-tableaggregations
  • Heaps, Sorting & SearchMediumAuto-graded
    Deadline-Priority Ordering of Dependent Jobs

    Produce an execution order for jobs with prerequisites by always running the ready job with the earliest deadline, breaking ties by id, using topological sort with a heap.

    Heaps, Sorting & Searchtopological-sortheapgraphpriority-queue
  • Heaps, Sorting & SearchMediumAuto-graded
    Boosting Your Budget With a Limited Number of Ventures

    Greedy selection with a sorted unlock pointer and a max-heap: repeatedly pick the most profitable venture whose entry threshold fits the current funds, up to a fixed number of picks.

    Heaps, Sorting & Searchheapgreedysortingpriority-queue
  • Heaps, Sorting & SearchMediumAuto-graded
    Smallest Conveyor Load Limit for Sequential Parcels

    Find the minimum per-day load limit that moves an ordered list of parcels in at most a given number of days, using binary search on the answer with a greedy feasibility check.

    Heaps, Sorting & Searchbinary-searchgreedysearch-on-answerarrays
  • Heaps, Sorting & SearchEasyAuto-graded
    Sort Array and Compute Unique Intersection

    Tests implementing custom merge sort to sort an array and finding the sorted unique intersection of two lists.

    Heaps, Sorting & Searchsortingmerge-sorthash-setarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Pick the Rank-k Score From the Top

    Select the k-th largest value, counting duplicates separately, from an unsorted integer list without a full sort, using quickselect or a bounded heap.

    Heaps, Sorting & Searchquickselectheapselectionpartitioning
  • Heaps, Sorting & SearchMediumAuto-graded
    Compute Safe Summary Statistics for Numeric Series

    Computes min, mean, and median robustly for floating-point data, handling missing/invalid values and large magnitude edge cases safely.

    Heaps, Sorting & Searchheaps-sortingarraysmath-bits
  • Heaps, Sorting & SearchMediumAuto-graded
    Running Leaderboard of the K Largest Readings

    Process paired operation and value lists, tracking the K largest integers seen so far and recording a descending snapshot after every operation, using a bounded min-heap.

    Heaps, Sorting & Searchheapstreamingtop-kpriority-queue
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate the Lone Value in a Sorted Paired List

    Use parity-based binary search on a sorted array of duplicated values to find the one value without a partner in logarithmic time and constant extra space.

    Heaps, Sorting & Searchbinary-searchsorted-arrayparityarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Shortest-Stack Block Placement Order

    Simulate placing blocks one at a time onto the currently lowest of k stacks, with ties going to the lowest index, and report each chosen stack; tests heap-based greedy simulation.

    Heaps, Sorting & Searchheappriority-queuegreedysimulation
  • Heaps, Sorting & SearchMediumModel answer
    Batched API Delivery with Delay-Aware Retries

    Deliver a list of requests through an API capped at five per call, retrying failures only after each request's own cooldown, without busy-waiting or blocking on one failure.

    Heaps, Sorting & Searchbatchingretryschedulingpriority-queue
  • Heaps, Sorting & SearchEasyAuto-graded
    Stream Median Tracker

    Process a series of dynamic data stream queries to compute the median on demand using heap-based structures.

    Heaps, Sorting & Searchheapsheapqdata-structuresdesign-ds
  • Heaps, Sorting & SearchMediumAuto-graded
    Combine Several Pre-Sorted Lists Into One Sorted List

    Tests merging K nondecreasing integer lists into a single sorted list, preserving duplicates and handling empty lists, using a heap or pairwise merging.

    Heaps, Sorting & Searchheapmergek-way-mergesorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Maximize Uniform Cut Length for Target Segment Count

    Find the maximum integer segment length that can produce at least a specified count of equal-sized pieces using binary search on answer.

    Heaps, Sorting & Searchbinary-searcharraysgreedy
  • Heaps, Sorting & SearchMediumModel answer
    Fill Spare Slots and Sort One Buffer In Place

    Combine two unsorted integer lists into the first, which has spare room at its end, so it ends up fully ascending, without using placeholder values to locate the data.

    Heaps, Sorting & Searcharrayssortingin-placeheapsort
  • Heaps, Sorting & SearchEasyAuto-graded
    Minimum Postponed Debits to Avoid Negative Balance

    Find the minimum number of negative transactions to postpone so that the running account balance remains non-negative throughout processing.

    Heaps, Sorting & Searchheaps-sortinggreedy-intervalsarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Longest Equal Cable Segment From Spools

    Find the largest integer segment length such that cutting every spool into equal segments yields at least k segments, using binary search on a monotonic feasibility check.

    Heaps, Sorting & Searchbinary-searchbinary-search-on-answermonotonic-predicatearrays
  • Heaps, Sorting & SearchMediumModel answer
    Exact Mode, Median and Balanced Sort Over Ten Message-Passing Nodes

    Integers live on ten machines that can only exchange messages. Write per-node programs for the exact mode, the median and a balanced global sort while sending as little data as possible.

    Heaps, Sorting & Searchdistributed-systemsmapreducesample-sortselection
  • Heaps, Sorting & SearchMediumAuto-graded
    Route Jobs to Workers with Account Stickiness

    Simulate FIFO dispatch of tasks to workers with a preference for each account's last worker, using heaps and a lookup table to track free and busy workers.

    Heaps, Sorting & Searchheapsimulationschedulinghash-map
  • Heaps, Sorting & SearchMediumAuto-graded
    Group and Rank Feed Items with Photo Bundling

    Rearrange feed items by sorting on rank score, grouping photos into batches of up to three, and maintaining stable ordering for equal scores.

    Heaps, Sorting & Searchsortingarraysbatching
  • Heaps, Sorting & SearchEasyAuto-graded
    Find the Slot for a Value in a Sorted List of Distinct Integers

    Tests explicit binary search on a sorted array: find a value's index or the position where it would be inserted, in logarithmic time.

    Heaps, Sorting & Searchbinary-searchsorted-arrayarraystwo-pointers
  • Heaps, Sorting & SearchMediumAuto-graded
    Top K Highest Scores in Descending Order

    Select the k greatest values from an unsorted integer list, duplicates included, returned from largest to smallest, ideally in O(n log k) time using a bounded min-heap.

    Heaps, Sorting & Searchheaptop-ksortingarrays
  • Heaps, Sorting & SearchMediumModel answer
    Quicksort vs Mergesort: Hardware, Stability and Disk Trade-offs

    Compare two O(n log n) sorts by how they use caches, preserve tie order, resist bad inputs, and behave when data lives on disk instead of in memory.

    Heaps, Sorting & Searchquicksortmergesortstabilitycache-locality
  • Heaps, Sorting & SearchMediumAuto-graded
    K-th Smallest Entry in a Row and Column Sorted Grid

    Find the k-th smallest value in a two-dimensional grid where every row and column is sorted in ascending order.

    Heaps, Sorting & Searchbinary-searchmatrixheaps-sorting
  • Heaps, Sorting & SearchMediumModel answer
    Two-Sided Order Book Matching with Unit Orders

    Simulate a simple exchange: buys and sells of size one arrive in sequence, cross against the best resting price, and you return the total value of all executed trades.

    Heaps, Sorting & Searchheappriority-queuesimulationorder-book
  • Heaps, Sorting & SearchMediumAuto-graded
    Longest Uniform Cut Length from Rope Pieces

    Find the largest integer length such that cutting every rope into pieces of that length yields at least k pieces; tests binary search over a monotonic answer space.

    Heaps, Sorting & Searchbinary-searchbinary-search-on-answermonotonic-predicatearrays
  • Heaps, Sorting & SearchHardAuto-graded
    Narrowest Window Touching Every Sorted Array

    Find the tightest inclusive interval that holds at least one value from each of several sorted arrays, using a k-way merge with a min-heap and a tracked maximum.

    Heaps, Sorting & Searchheapk-way-mergesorted-liststwo-pointers