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 61–90 of 200 results

  • Heaps, Sorting & SearchMediumAuto-graded
    Lowest K Values in Ascending Order with Duplicates

    Select the k smallest values from an unsorted integer list, keeping duplicates and returning them sorted ascending, which tests heap, sorting and selection trade-offs.

    Heaps, Sorting & Searchheapsortingselectiontop-k
  • Heaps, Sorting & SearchMediumAuto-graded
    Determine Available Range on Number Line

    Evaluate dynamic range-query operations on 1D coordinates to test whether continuous subsegments contain obstacles.

    Heaps, Sorting & Searchheaps-sortingbinary-searchfenwick-treesegment-tree
  • Heaps, Sorting & SearchMediumAuto-graded
    Evaluate a Piecewise Linear Curve From Shuffled Sample Points

    Build a piecewise linear function from unordered sample points and evaluate it at one query, extending the end segments outward, using sorting and binary search.

    Heaps, Sorting & Searchbinary-searchsortinginterpolationfloating-point
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate the K-th Dominant Value

    Find the k-th largest integer in an unsorted list efficiently using quickselect or priority queues.

    Heaps, Sorting & Searchheaps-sortingarraysquickselect
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Unique Combination Triples for Target Sum

    Find all distinct non-decreasing 3-element value combinations in an array that add up to a specified target value.

    Heaps, Sorting & Searcharrayssortingtwo-pointers
  • Heaps, Sorting & SearchMediumAuto-graded
    Simulate Multi-Timer Expiry with Single System Timer

    Simulate the execution and triggering order of multiple scheduled timers using a min-heap under system clock advancements.

    Heaps, Sorting & Searchheappriority-queuedesignsimulation
  • Heaps, Sorting & SearchMediumAuto-graded
    Lowest-Sum Pairs Across Two Sorted Lists

    Select the k cheapest cross-array pairs from two sorted lists using a heap-based k-way merge, with a deterministic ordering for ties.

    Heaps, Sorting & Searchheapk-way mergesorted arrayspriority queue
  • Heaps, Sorting & SearchMediumAuto-graded
    Budget Growth Through Threshold-Locked Ventures

    Greedy plus min-sorted unlocking and a max-heap: pick up to k ventures, each requiring a minimum budget, to maximize the final budget.

    Heaps, Sorting & Searchgreedyheapsortingpriority-queue
  • Heaps, Sorting & SearchMediumModel answer
    Random Index Selection by Given Weights

    Design an index sampler where each element's probability of being chosen is proportional to its assigned weight.

    Heaps, Sorting & Searchprefix-sumbinary-searchrandomizationdata-structure-design
  • Heaps, Sorting & SearchMediumAuto-graded
    Locate the Span of a Value in a Sorted List

    Use binary search to find the first and last positions of a value in a sorted list with duplicates, in logarithmic time, returning [-1, -1] if it is absent.

    Heaps, Sorting & Searchbinary-searcharraysbisectsorted-array
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Array Peak Index and Form Unique Word Abbreviation List

    Locate a local peak index in an array via binary search and generate minimal unambiguous string abbreviations for a list of words.

    Heaps, Sorting & Searchbinary-searchstringshash-maparrays
  • Heaps, Sorting & SearchHardAuto-graded
    Ranked Element Selection and Common Entry Count in Sorted Arrays

    Find the k-th smallest element across two sorted arrays and count their unique shared elements efficiently.

    Heaps, Sorting & Searchheaps-sortingarraysbinary-search
  • Heaps, Sorting & SearchMediumAuto-graded
    Final Departure From a Bouncing Convoy on a Road

    Find when the last vehicle leaves a segment and which one it is, when equal-speed vehicles reverse on contact, using pass-through equivalence and order preservation.

    Heaps, Sorting & Searchsortingsimulation-shortcutghost-particlesordering-invariant
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Boundary Indices in Sorted Sequence

    Adapt binary search to locate the starting and ending index of a target value in a sorted sequence in logarithmic time.

    Heaps, Sorting & Searchbinary-searcharrayssearching
  • Heaps, Sorting & SearchEasyAuto-graded
    Combine and Sort Two Unordered Integer Sequences

    Merge two unordered arrays of integers into a single list arranged in non-decreasing order.

    Heaps, Sorting & Searchsortingarraysfundamentals
  • Heaps, Sorting & SearchMediumAuto-graded
    Kth Biggest Value Across a Pair of Ascending Lists

    Find the kth largest value in the union of two ascending integer lists, counting duplicates, ideally using binary search on a partition instead of a full merge.

    Heaps, Sorting & Searchbinary-searchsorted-arraysorder-statisticstwo-arrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Order Trading Strategies by Chance of a Positive Day

    Rank strategies by the chance of a positive next-day return, using a predictive spread that includes both daily volatility and uncertainty in the estimated mean.

    Heaps, Sorting & Searchsortingstatisticscustom-keyprobability
  • Heaps, Sorting & SearchHardAuto-graded
    Priority Task Scheduler with Tag Filtering and Splicing

    Schedule tasks subject to dependency constraints, priority ordering, tag-based task filtering with dependency splicing, and cycle detection.

    Heaps, Sorting & Searchheaps-sortingtrees-graphstopological-sort
  • Heaps, Sorting & SearchMediumAuto-graded
    Unique Union of Several Pre-Sorted Lists

    Combine many ascending integer lists into one ascending list with each distinct value appearing once, ideally using a heap-based k-way merge.

    Heaps, Sorting & Searchheapk-way-mergededuplicationsorted-arrays
  • Heaps, Sorting & SearchMediumAuto-graded
    Maximum Concatenation of Nonnegative Integers

    Order a list of nonnegative integers so that joining their decimal forms gives the biggest possible number, using a pairwise concatenation comparator and handling the all-zero case.

    Heaps, Sorting & Searchsortingcustom-comparatorstringsgreedy
  • Heaps, Sorting & SearchMediumModel answer
    Design a Single-Threaded Delayed Task Runner

    Implement a priority-queue task runner that handles delayed execution without busy-waiting.

    Heaps, Sorting & Searchheappriority-queuedesign-dstime-complexity
  • Heaps, Sorting & SearchMediumModel answer
    Design and Analyze an Intentionally Inefficient Correct Sorting Algorithm

    Propose a fully correct yet highly inefficient sorting algorithm, prove its termination and correctness, and derive its time and space complexity.

    Heaps, Sorting & Searchsortingcomplexity-analysiscombinatoricsrecursion
  • Heaps, Sorting & SearchMediumAuto-graded
    Weighted Distribution Sampling from Uniform Draws

    Validate probability weights and map pre-generated uniform float values to discrete outcomes using prefix sums and binary search.

    Heaps, Sorting & Searcharraysbinary-searchmathvalidation
  • Heaps, Sorting & SearchMediumAuto-graded
    Determine the K-th Highest Score in an Unsorted Array

    Find the k-th largest value in an unsorted array of integers without fully sorting the input.

    Heaps, Sorting & Searcharrayssortingdivide-and-conquerquickselect
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Frequent Elements with Custom Tie-Breaking

    Count item occurrences and retrieve the top k highest-frequency elements, sorting tied elements by value ascending.

    Heaps, Sorting & Searcharrayssortinghash-table
  • Heaps, Sorting & SearchMediumAuto-graded
    Newest-First Transaction Pager with Offset and Cursor Modes

    Build a pager over transaction records that sorts newest-first with a deterministic tie-break and supports offset and keyset-cursor navigation with correct metadata.

    Heaps, Sorting & Searchsortingpaginationkeyset-cursortie-breaking
  • Heaps, Sorting & SearchMediumAuto-graded
    Find Pair of Integers with Sum Nearest to Zero

    Find a pair of distinct elements in an array whose sum has the smallest absolute value, breaking ties deterministically.

    Heaps, Sorting & Searcharraysbinary-searchsortingtwo-pointers
  • Heaps, Sorting & SearchMediumAuto-graded
    Generate Unique Lexicographical Permutations

    Enumerate all unique permutations of an integer list containing duplicates in lexicographically sorted order.

    Heaps, Sorting & Searcharrayssortingbacktrackingrecursion
  • Heaps, Sorting & SearchMediumModel answer
    Find Frequent Elements in Large-Scale Data Streams

    Design scalable algorithms to extract the top K most frequent elements from a data stream under both memory-bounded exact and memory-constrained approximate regimes.

    Heaps, Sorting & Searchheaps-sortingdesign-dsarrays
  • Heaps, Sorting & SearchHardAuto-graded
    Gift Card Waterfall, ZIP Surcharges and Refund Credits

    Simulate a stream of purchase and refund events that drain gift cards by expiry priority, surcharge the card remainder by ZIP range, and turn excess refunds into store credit.

    Heaps, Sorting & Searchsimulationheappriority-queuebinary-search