KatInterview

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

Arrays & Hashing Interview Problems

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

5965
Problems
2208
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 40 results

  • Arrays & HashingMediumModel answer
    Weighted Random Index Sampling and Exclusion Product Array

    Implement weighted index sampling with binary search and an exclusion product array without division in O(1) auxiliary space.

    Arrays & Hashingarraysbinary-searchprefix-sum
  • Arrays & HashingHardModel answer
    Distinct Subset Sums With Negatives and Repeated Values

    List every distinct multiset of array values, each index used at most once, that sums to a target when negatives, zeros and duplicates are present. Output must be sorted.

    Arrays & Hashingbacktrackingpruningdeduplicationsubsets
  • Arrays & HashingMediumModel answer
    Cyclic Shifts and Cell-Level Keyword Lookup in CSV Text

    Shift an integer array left or right by k using modular arithmetic, then locate every occurrence of one or more keywords in a simple CSV string, reporting row, column and offset in the cell.

    Arrays & Hashingarray-rotationmodular-arithmeticstring-searchcsv-parsing
  • Arrays & HashingMediumModel answer
    Detect 8-Hour Cooling Streaks in a Flaky Forecast Feed

    Build a service that checks a city's latitude, pulls a 72-hour forecast from an unreliable API with proper retries, and returns every 8-hour span of strictly falling, gapless hourly temperatures.

    Arrays & Hashingsliding-windowretry-backoffapi-integrationerror-handling
  • Arrays & HashingEasyModel answer
    Clean and Reconcile Account Snapshots from a JSON Feed

    Parse a JSON list of account records with exact decimal arithmetic, drop invalid rows, keep the newest record per account, and report a rounded total plus a per-account map.

    Arrays & Hashingpythonjsondecimaldeduplication
  • Arrays & HashingMediumModel answer
    Fix a Failing Budget-Check Module and Add Regression Tests

    Debug a small spending-limit module with failing tests: find root causes, fix them, add minimal regression tests, and explain your debugging process and tools.

    Arrays & Hashingdebuggingunit-testingroot-cause-analysisfloating-point
  • Arrays & HashingMediumModel answer
    Distance-to-Go Along Batched 2D Routes

    Given a batch of 2D routes, compute for each waypoint the length of the remaining route to the final waypoint, in linear time, handling short and empty inputs.

    Arrays & Hashingsuffix-sumnumpyvectorizationeuclidean-distance
  • Arrays & HashingMediumModel answer
    Best Single Trade Within a Limited Holding Period

    Find the most profitable buy-then-sell pair in a price array when the sale must happen within D days of the purchase, in O(n) time and O(1) extra space.

    Arrays & Hashingsliding-windowblock-decompositionmonotonic-dequestock-trading
  • Arrays & HashingMediumModel answer
    Code Review Drill: Three Pandas Helpers in a Data Pipeline

    Explain what three short pandas helper functions do, then propose and justify improvements to their correctness, speed, readability, robustness and testability.

    Arrays & Hashingpythonpandascode-reviewvectorization
  • Arrays & HashingMediumModel answer
    Uniform Random Array Partitioning into K Segments

    Divide an array into K non-empty contiguous slices such that every valid partition is equally likely to be selected.

    Arrays & Hashingarraysmath-bitsheaps-sorting
  • Arrays & HashingMediumModel answer
    Paginated API Fetching and Data Merging

    Fetch paginated JSON payloads from two separate endpoints, defensively clean and transform records, and merge them on a common key preserving the original sequence.

    Arrays & Hashingpaginationhttp-requestshash-tabledata-cleaning
  • Arrays & HashingMediumModel answer
    Modern Java 8 Toolkit: Lambdas, Streams, Optional, java.time

    Explain the major Java 8 language and library additions, when each one fits, and the common pitfalls, using short code examples.

    Arrays & Hashingjavajava-8lambdasstreams
  • Arrays & HashingMediumModel answer
    Solving Multi-Task Online Assessment Challenges

    A guide to solving four standard assessment tasks: cumulative running totals, step-by-step array reduction, deterministic matrix block placement, and linear arithmetic series optimization.

    Arrays & Hashingarrayssimulationgridoptimization
  • Arrays & HashingMediumModel answer
    Simulate Grid Rover Fleet Collision Logic

    Simulate the concurrent step-by-step navigation of multiple automated grid rovers, handling collisions, static obstacles, and grid bounds.

    Arrays & Hashingarrayssimulationmatrixhash-table
  • Arrays & HashingMediumModel answer
    Simulate Cascade Board Game Outcome

    Simulate a custom board game involving stack placing and directed toppling moves to determine the game outcome.

    Arrays & Hashingarrayssimulationmatrix
  • Arrays & HashingMediumModel answer
    Cart Pricing Engine: Offers, Cheapest Deal, Aisle Sort

    Parse cart records, total units and price in integer cents, apply the best percent-off or buy-N-get-M-free deal per product, then sort items by aisle with frozen goods at the end.

    Arrays & Hashingparsingmoney-arithmeticextensible-designsorting
  • Arrays & HashingMediumModel answer
    Scoring Parsed Payroll Form Output Against Ground Truth

    Write a scorer that compares fields extracted from tax forms to a ground-truth mapping, normalizing keys and currency, then reporting match rate, missing and mismatched fields, and precision/recall.

    Arrays & Hashingdata-normalizationhash-mapsevaluation-metricsprecision-recall
  • Arrays & HashingMediumModel answer
    Merging k Key-Value Maps: Conflict Rules and Efficient Design

    Design a way to merge two key-value maps, extend it to k maps, and decide which conflict rules must be pinned down before writing any code.

    Arrays & Hashinghash-mapmergingapi-designclarifying-questions
  • Arrays & HashingMediumModel answer
    Randomly Fill Ad Slots Under Per-User View Caps

    Randomly assign eligible ads to page positions for one user, respecting per-user display caps, avoiding repeats when possible, and returning the updated view counts.

    Arrays & Hashingrandomizationhash-mapshuffleresource-allocation
  • Arrays & HashingMediumModel answer
    Test Plan for Straight-Line vs Path Word Search

    Build a TDD plan, concrete cases, property invariants and stress tests for two grid word-search functions that must disagree on key inputs.

    Arrays & Hashingtestingtddgridsbacktracking
  • Arrays & HashingMediumModel answer
    Splitting Strings and Batching Equal-Cost Item Pairs

    Count splits where prefix and suffix share more than k letters, then find the target cost that yields the most single-or-pair packages.

    Arrays & Hashingcountingfrequency-arrayshash-mapcombinatorics
  • Arrays & HashingMediumModel answer
    Column-Normalize a Random Binary Matrix

    Generate an n×n matrix of fair coin-flip entries and rescale each column so its values sum to 1, in O(n²) time.

    Arrays & Hashingnumpymatrixnormalizationvectorization
  • Arrays & HashingMediumModel answer
    Circular Token Distribution on a Ring of Nodes

    Distribute k tokens clockwise across n nodes in a ring starting at a given index, returning each node's final count without simulating one token at a time.

    Arrays & Hashingarraysmathmodulo arithmetic
  • Arrays & HashingEasyModel answer
    Weighted Random Item Picker from Scratch

    Implement a function that draws one item from a list at random, where each item's selection probability is proportional to its given weight.

    Arrays & Hashingprobabilityprefix-sumbinary-search
  • Arrays & HashingMediumModel answer
    Walk Through Your Subarray Solution and Its Trade-offs

    Given a solution to a subarray-sum problem, explain your approach, prove it correct, analyze complexity, and compare it to at least two alternatives.

    Arrays & Hashingprefix-sumhash-mapcomplexity-analysiscommunication
  • Arrays & HashingMediumModel answer
    Layered Invoice Processor with Discounts, Tax, and FX

    Build a multi-part order cost engine that handles input validation, per-item discounts, order-level tax, multi-currency conversion, and banker's rounding.

    Arrays & Hashingdata-processingdecimal-arithmeticinput-validationsorting
  • Arrays & HashingMediumModel answer
    Writing Test Cases for Array and String Problems

    Design a systematic testing strategy for array and string coding problems, covering edge cases, validation, and stress testing.

    Arrays & Hashingtestingedge-casesdebugging
  • Arrays & HashingHardModel answer
    Fewest Swaps to Bring an Array with Duplicates into Sorted Order

    Given an integer array that may contain duplicates, find the minimum number of arbitrary index swaps needed to sort it in non-decreasing order.

    Arrays & Hashingsortingpermutationscycle-detectiongreedy
  • Arrays & HashingMediumModel answer
    Peak Average Score: Overflow, Large Files, and Java Concurrency

    Aggregate student scores to find the highest per-student average, then extend the solution for huge files, negative values, integer overflow, and multithreaded processing.

    Arrays & Hashingjavaconcurrencyaggregationinteger-overflow
  • Arrays & HashingMediumModel answer
    Simulating Motion Under Time-Varying Visibility Constraints

    Determine how many entities moving rightward on a line reach a target position when their movement is blocked by a direction-switching observer.

    Arrays & Hashingsimulationbinary-searchprefix-sum