KatInterview

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

Heaps, Sorting & Search Interview Problems

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

5969
Problems
2211
Auto-graded
15
Topics
273
Added today

Showing 151–180 of 200 results

  • Heaps, Sorting & SearchMediumAuto-graded
    Minimum Cost to Combine All Elements

    Tests greedy algorithm design and min-heap operations to repeatedly merge pairs optimally.

    Heaps, Sorting & Searchheapgreedypriority-queue
  • Heaps, Sorting & SearchHardModel answer
    Binary Search with Delayed Feedback Protocol

    Find a hidden number using binary search when each query returns the result of your previous guess instead of your current one.

    Heaps, Sorting & Searchbinary-searchalgorithmsfeedback-systems
  • Heaps, Sorting & SearchMediumAuto-graded
    Collapse Repeat Visits and Order the Result

    Tests array manipulation, hash-based deduplication, and implementing an O(n log n) sort from scratch without relying on built-in sort utilities.

    Heaps, Sorting & Searcharrayssortinghashingheapsort
  • Heaps, Sorting & SearchMediumAuto-graded
    Minimum Relay Power for Full Network Coverage

    Tests binary search on the answer combined with a greedy coverage check to find the minimum broadcast power so every city is reachable from a central hub.

    Heaps, Sorting & Searchbinary searchgreedysorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Top-K Cutoff: Find the K-th Highest Value

    Tests order-statistics intuition by asking candidates to extract the k-th largest element from an unsorted array without a full sort.

    Heaps, Sorting & Searchheapsortingorder-statistics
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Target Index in Sorted Array

    Tests ability to implement iterative binary search with correct loop invariants, boundary handling, and termination conditions.

    Heaps, Sorting & Searchbinary-searcharraysiterativealgorithm-implementation
  • Heaps, Sorting & SearchMediumAuto-graded
    Busiest Conference Room Tracker

    Tests the ability to simulate event scheduling with delayed assignments using two priority queues to track which resource handles the most requests.

    Heaps, Sorting & Searchheapsimulationgreedypriority-queue
  • Heaps, Sorting & SearchMediumAuto-graded
    Top-K Price Harvest from Tiered Stock Levels

    Tests whether a candidate can reformulate a greedy revenue problem into summing the largest elements across union-of-range price sets and implement an O(n log n) layer-sweep solution.

    Heaps, Sorting & Searchgreedysortingmath
  • Heaps, Sorting & SearchMediumAuto-graded
    K Nearest Points to Origin

    Tests heap-based selection and distance computation to efficiently find the k points closest to the origin in 2D space.

    Heaps, Sorting & Searchheapdistanceselectionoptimization
  • Heaps, Sorting & SearchMediumAuto-graded
    Find K Closest Elements in Sorted Array

    Tests binary search on sorted arrays to locate a contiguous window of k elements with minimum distance to a target value.

    Heaps, Sorting & Searchbinary-searchtwo-pointerssliding-window
  • Heaps, Sorting & SearchMediumAuto-graded
    Kth Element in Union of Two Sorted Lists

    Tests ability to find the kth smallest element from two sorted arrays using binary search on partition counts rather than merging.

    Heaps, Sorting & Searchbinary-searcharraystwo-pointers
  • Heaps, Sorting & SearchHardAuto-graded
    Select Best Available Venues by Ranking Criteria

    Tests filtering, multi-level sorting with custom tie-breaking rules, and efficient top-K selection from structured data.

    Heaps, Sorting & Searchsortingfilteringheappriority-queue
  • Heaps, Sorting & SearchEasyAuto-graded
    Combine Multiple Sorted Lists into a Single Sorted Sequence

    Tests divide-and-conquer merging and two-pointer techniques to efficiently combine many pre-sorted lists.

    Heaps, Sorting & Searchdivide-and-conquertwo-pointersmerging
  • Heaps, Sorting & SearchMediumAuto-graded
    Combine K Sorted Sequences into One

    Tests whether a candidate can use a min-heap to efficiently merge multiple sorted lists into a single sorted output in O(N log k) time.

    Heaps, Sorting & Searchheapmergesorting
  • Heaps, Sorting & SearchMediumModel answer
    Streaming Weighted Reservoir Sampling Without Replacement

    Implement a single-pass, memory-efficient weighted sampler that draws k distinct items proportional to weight from a potentially huge stream.

    Heaps, Sorting & Searchreservoir-samplingprobabilitynumerical-stabilityheap
  • Heaps, Sorting & SearchMediumAuto-graded
    Binary Search Over a Row-Chained Sorted Grid

    Tests whether a candidate can exploit strict row-chaining in a sorted matrix to locate a target value in O(log(m·n)) time using a single binary search.

    Heaps, Sorting & Searchbinary-searcharraysmatrix
  • Heaps, Sorting & SearchMediumAuto-graded
    Merge Sorted Streams with Memory Constraint

    Tests heap-based merging of multiple sorted sequences under strict O(k) space while maintaining stable duplicate handling.

    Heaps, Sorting & Searchheapsortingmergespace-complexity
  • Heaps, Sorting & SearchMediumAuto-graded
    Greedy Task Merging and Segment Removal Cost

    Tests greedy heap-based merge cost minimization and prefix-sum sliding-window removal to minimize adjacent absolute differences.

    Heaps, Sorting & Searchgreedyheapprefix-sumssliding-window
  • Heaps, Sorting & SearchMediumAuto-graded
    Slice a Sorted Event Stream by Timestamp Window

    Tests binary search boundary reasoning on a sorted sequence with duplicate timestamps and inclusive range semantics.

    Heaps, Sorting & Searchbinary-searcharrayssorting
  • Heaps, Sorting & SearchMediumAuto-graded
    K Nearest Value Pairs in a Sorted Sequence

    Tests whether a candidate can efficiently extract the k pairs with smallest gap from a sorted array using a heap-based k-way merge instead of brute force enumeration.

    Heaps, Sorting & Searchheapsortingtwo-pointersarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Select K Elements with Highest Occurrence Count

    Tests frequency counting with hash maps and efficient selection of top elements using heap-based algorithms.

    Heaps, Sorting & Searchhash-mapheapcountingfrequency-analysis
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Path with Highest Bottleneck Value in Grid

    Tests combining priority-queue graph traversal with bottleneck optimization to find the path whose minimum cell value is maximized.

    Heaps, Sorting & Searchgraph-traversaldijkstrabinary-searchunion-find
  • Heaps, Sorting & SearchMediumAuto-graded
    Running Median with Power-of-Two Bucket Tracking

    Tests two-heap streaming median maintenance combined with exact integer floor-log₂ bucketing to place each median into its enclosing power-of-two interval.

    Heaps, Sorting & Searchheapsmedianbit-manipulation
  • Heaps, Sorting & SearchHardAuto-graded
    Build a Min-Heap and Schedule Tasks by Priority

    Construct a working min-heap from scratch, then apply it to schedule dependent tasks in lexicographic order while detecting cycles.

    Heaps, Sorting & Searchheaptopological-sortgraphdata-structures
  • Heaps, Sorting & SearchMediumAuto-graded
    Minimize the Maximum Delivery Time Across Routes

    Tests binary search on the answer combined with greedy feasibility checking to minimize the maximum delivery time when assigning parcels to couriers.

    Heaps, Sorting & Searchbinary searchgreedysorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Minimum Bandwidth to Stream All Files Within Deadline

    Tests binary search on the answer to find the minimum integer bandwidth that allows streaming a list of files (each with a size and deadline) without missing any deadline using a greedy scheduler.

    Heaps, Sorting & Searchbinary searchgreedysorting
  • Heaps, Sorting & SearchMediumAuto-graded
    Build Three-Color Outfits from Limited Inventory

    Tests greedy allocation with heap-based selection and mathematical reasoning about resource constraints under distinct-element requirements.

    Heaps, Sorting & Searchgreedyheapcombinatorics
  • Heaps, Sorting & SearchMediumAuto-graded
    Sort a Large Sequence Using Memory-Bounded Runs and a Heap

    Tests knowledge of two-phase external sorting: chunking a sequence into fixed-size sorted runs, then merging them efficiently with a min-heap.

    Heaps, Sorting & Searchheapsortingmergesimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Win Rate Between Two Weighted Dice

    Tests whether a candidate can count strict-win outcome pairs across two multi-faced dice efficiently using sorting and binary search instead of a brute-force double loop.

    Heaps, Sorting & Searchbinary-searchsortingprobabilityarrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Leftmost Position Meeting Threshold

    Tests understanding of lower-bound binary search with correct boundary handling and duplicate treatment.

    Heaps, Sorting & Searchbinary-searchboundariesduplicates