KatInterview

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

Arrays & Hashing Interview Problems

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

5981
Problems
2215
Auto-graded
15
Topics
272
Added today

Showing 241–270 of 477 results

  • Arrays & HashingMediumAuto-graded
    Deterministic Mini-Batch Gradient Descent for a Line Fit

    Fit a slope and intercept to 2D points by running deterministic mini-batch gradient descent on mean squared error, with exact batching, update order and edge-case rules.

    Arrays & Hashinggradient-descentlinear-regressionmini-batchoptimization
  • Arrays & HashingMediumAuto-graded
    Rank Among Values Occurring Once Across Two Lists

    Count occurrences across two combined lists, keep values seen exactly once, and return the k-th largest of them or -1 if there are fewer than k.

    Arrays & Hashinghash-mapcountingsortingheap
  • Arrays & HashingMediumAuto-graded
    Fill a Padded Sorted Buffer from a Second Sorted List

    Merge two sorted lists into the first, which has trailing spare slots, without extra memory; tests back-to-front two-pointer merging.

    Arrays & Hashingtwo-pointersin-placesortingmerge
  • Arrays & HashingEasyAuto-graded
    Bump a Digit-Array Number Up by One

    Increment a large non-negative number stored as a digit list by one, handling carry propagation and length growth without converting to an integer.

    Arrays & Hashingarrayscarrysimulationmath
  • Arrays & HashingMediumAuto-graded
    Probability Toolkit: Gamble Moments, Dice, Arrivals, Odds, Draws

    Compute expected value and variance, a dice conditional probability, a Poisson tail, betting edge with Kelly sizing, and a without-replacement card probability in one function.

    Arrays & Hashingprobabilityexpected-valueconditional-probabilitypoisson
  • Arrays & HashingEasyAuto-graded
    Rolling window totals over filtered records in input order

    Tests filtering a list of tagged records and computing rolling window totals in O(n) using an incremental sum instead of recomputing each window.

    Arrays & Hashingsliding-windowprefix-sumfilteringarrays
  • Arrays & HashingMediumAuto-graded
    Detect a Run of Two or More Elements Summing to a Multiple of k

    Tests prefix-sum reasoning with hashing: detecting a contiguous run of length at least two whose sum is divisible by k, including the k = 0 special case.

    Arrays & Hashingprefix sumhash mapremainderssubarray
  • Arrays & HashingHardAuto-graded
    Maximize Total Distinct Values Across Two Arrays

    Tests greedy reasoning, frequency counting, and backtracking search to maximize the combined distinct-value count across two arrays given a limited swap budget.

    Arrays & Hashingbacktrackinggreedyfrequency-counting
  • Arrays & HashingEasyAuto-graded
    Daily and Rolling Active User Counts with Zero-Fill

    Tests building a complete calendar spine, counting distinct daily users, and maintaining a 30-day rolling active-user window.

    Arrays & Hashinghash-mapsliding-windowdate-manipulation
  • Arrays & HashingHardAuto-graded
    Three-in-a-Row: Find the Winner on a 3×3 Grid

    Tests whether you can encode all win conditions for a 3×3 grid as data and apply a uniform check to identify a winning player.

    Arrays & Hashingarraysgame-theorysimulation
  • Arrays & HashingEasyAuto-graded
    Closest Pair of Target Words

    Find the minimum index gap between any occurrence of two distinct words in a list using single-pass tracking.

    Arrays & Hashingarraystringsingle-passtwo-pointer
  • Arrays & HashingMediumAuto-graded
    Find User Pairs with Enough Overlapping Interests

    Tests your ability to invert a membership index and use co-occurrence counting to efficiently find all pairs sharing at least k common items.

    Arrays & Hashinghash-mapsetsco-occurrenceinverted-index
  • Arrays & HashingMediumAuto-graded
    Trim a Record List to a Token Budget with a Sliding Window

    Tests the sliding-window technique: conditionally compact a list of records to the longest contiguous run whose token sum fits a given budget.

    Arrays & Hashingsliding-windowarraystwo-pointers
  • 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 & HashingMediumAuto-graded
    Track Items Surviving Sequential Shifts on a Grid

    Determine which grid cells remain in bounds after a sequence of directional shifts, testing displacement tracking and boundary analysis.

    Arrays & Hashingsimulation2d-arrayprefix-summath
  • Arrays & HashingMediumAuto-graded
    Momentum-Weighted Portfolio: Daily Log Return Statistics

    Tests simulation of a daily rebalancing strategy where portfolio weights are proportional to positive asset returns, requiring correct timeline logic and statistical output.

    Arrays & Hashingsimulationfinancestatistics
  • 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 & HashingMediumAuto-graded
    Overlapping 2D Block Move with O(1) Extra Memory

    Tests whether a candidate can copy a rectangular subregion of a 2D grid onto another position in the same grid, in place, without corrupting overlapping data.

    Arrays & Hashingarraysin-placetwo-dimensional
  • 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 & HashingMediumAuto-graded
    Shortest Window With Unique-Value Sum Meeting a Goal

    Sliding-window task where the window score is the sum of its distinct values, not the plain sum of its elements.

    Arrays & Hashingsliding-windowhash-maptwo-pointersarrays
  • 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 & HashingEasyAuto-graded
    Paginated Sensor-Alert Filter with Validation

    Tests ability to validate, filter, sort, and paginate structured records while handling malformed entries and boundary conditions correctly.

    Arrays & Hashingarraysfilteringpagination
  • Arrays & HashingMediumAuto-graded
    Bayesian Guessing Game with Unknown Coin Bias

    Compute expected optimal winnings when sequentially guessing coin flips with a uniform-prior unknown bias.

    Arrays & Hashingprobabilitybayesianexpected-valuedynamic-programming
  • 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 & HashingMediumAuto-graded
    Longest Contiguous Subarray with a Target Sum

    Tests prefix-sum reasoning, hash-map lookups, and precise tie-breaking to find the longest subarray summing to exactly k.

    Arrays & Hashingprefix-sumshash-maparrays
  • Arrays & HashingEasyAuto-graded
    Aggregate Parallel Pipeline Results Safely

    Fix async pool usage so results are collected in order, worker errors surface, and one JSON file is written.

    Arrays & Hashingmultiprocessingconcurrencydebuggingfile-io
  • Arrays & HashingMediumAuto-graded
    Compress Sorted Array to Unique Elements

    Tests in-place array manipulation with two-pointer technique to remove duplicates from a sorted sequence.

    Arrays & Hashingtwo-pointersin-placesorted-array
  • Arrays & HashingMediumAuto-graded
    Three-Dice Payout: Expected Value by Match Type

    Tests ability to count outcome classes for three N-sided dice and combine probability-weighted payoffs into an expected value, including a sign-flip variant.

    Arrays & Hashingexpected-valueprobabilitycounting
  • Arrays & HashingMediumAuto-graded
    K-Means Clustering: Assignment, Update, and Convergence

    Tests ability to implement the full k-means loop — initialization, Euclidean assignment, centroid update, convergence check, and empty-cluster handling — in plain Python.

    Arrays & Hashingclusteringiterative-algorithmsnumerical