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 474 results

  • Arrays & HashingMediumAuto-graded
    Shortest Window Holding Exactly k Different Values

    Find the shortest contiguous slice of an integer list containing exactly k different values, using a sliding window with frequency counts.

    Arrays & Hashingsliding-windowhash-mapsubarraytwo-pointers
  • Arrays & HashingEasyAuto-graded
    Check a Call Against a Catalog of Function Signatures

    Decide whether an ordered list of argument types fits any function in a catalog, given required, trailing optional, and variadic parameters with exact type matching.

    Arrays & Hashingsimulationarray-scanningsignature-matchingedge-cases
  • Arrays & HashingMediumAuto-graded
    Shortest Subarray with K Unique Values

    Find the minimum length of a contiguous subarray containing at least K unique elements using a sliding window.

    Arrays & Hashingsliding-windowtwo-pointershash-tablearrays
  • Arrays & HashingEasyAuto-graded
    Maximum Gain from Single Asset Trade

    Determine the maximum possible gain achieved by completing at most one purchase and sale transaction over a sequence of prices.

    Arrays & Hashingarraysgreedyprefix-minimum
  • Arrays & HashingMediumAuto-graded
    Leave-One-Out Products Without Using Division

    Build an array where each entry is the product of all other entries, without division, in linear time, using prefix and suffix running products.

    Arrays & Hashingprefix-productsuffix-productarrayin-place
  • Arrays & HashingMediumAuto-graded
    Per-Move Win Tracker for a Square Noughts-and-Crosses Grid

    Replay a sequence of marks on an n-by-n grid and report after each one whether the mover has completed a row, column or diagonal, using per-line counters.

    Arrays & Hashingsimulationcountingmatrixdiagonals
  • Arrays & HashingEasyAuto-graded
    Find Peak Positions in an Integer Sequence

    Scan an integer list and return the indices of elements strictly larger than every neighbor that exists, handling the ends, plateaus, and tiny inputs correctly.

    Arrays & Hashingarraystraversalboundary-conditions
  • Arrays & HashingMediumAuto-graded
    Quickest Kilometer Within a Run Recorded in 5-Second Splits

    Find the highest average speed over any 1000 m stretch of a run given per-5-second distances, using prefix sums, binary search and interpolation at boundaries.

    Arrays & Hashingprefix-sumsbinary-searchsliding-windowinterpolation
  • Arrays & HashingEasyAuto-graded
    Earliest Strict Valley in an Integer Sequence

    Scan an integer list for the leftmost interior value strictly smaller than both adjacent values, returning -1 if none exists, which tests boundary handling and strict comparisons.

    Arrays & Hashingarrayscanboundary-conditionsstrict-comparison
  • Arrays & HashingMediumAuto-graded
    Chain-Reaction Tile Clearing on a Grid

    Simulate a grid game where runs of three or more equal tiles vanish together, tiles fall down, and the process repeats until the grid is stable.

    Arrays & Hashingsimulationmatrixtwo-pointersgrid
  • Arrays & HashingMediumAuto-graded
    Find Members Missing a Nearby Provider Specialty

    Given providers and members on a 2D plane, find members with a required specialty that has no provider within a distance limit, using hashing and spatial grouping.

    Arrays & Hashinghashinggeometrygrid-bucketingsimulation
  • Arrays & HashingEasyAuto-graded
    Longest Strictly Rising Streak in a Row of Readings

    Scan an integer list once to find the longest block of adjacent, strictly rising values, handling empty input, equal neighbors, and runs that reach the end.

    Arrays & Hashingarrayssliding-windowtwo-pointerslinear-scan
  • Arrays & HashingMediumAuto-graded
    First-Week Post Totals and Week-Later Return Share

    Group dated activity rows by user, find each user's earliest date, total posts in the first seven days, and compute the share of users active on day 7 or later.

    Arrays & Hashinghash-mapdatesaggregationcohort-analysis
  • 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 & HashingEasyAuto-graded
    Ledger Replay Cleanup: Apply Each Payment Event Once

    Process a stream of possibly redelivered payment events and compute final account balances by applying each unique event ID only once.

    Arrays & Hashinghash-sethash-mapdeduplicationsimulation
  • Arrays & HashingMediumAuto-graded
    Shortest Total Flight on a Circular Track of Stations

    Sum the shortest arc distances between consecutive stops on a ring with weighted edges, using prefix sums for O(1) arc queries.

    Arrays & Hashingprefix-sumcircular-arraysimulation
  • Arrays & HashingHardAuto-graded
    Identify Most Popular Three-Page User Sequence

    Process website activity logs to compute chronological 3-site visit subsequences and find the most widely performed pattern across unique users.

    Arrays & Hashingarrayshash-tablesortingsubsequence
  • Arrays & HashingEasyAuto-graded
    Rank Companion Items by Shared Collections

    Count how often each item shares a collection with a target item, then rank by count descending and name ascending, with an optional cap on the result length.

    Arrays & Hashinghash-mapcountingsortingco-occurrence
  • Arrays & HashingMediumAuto-graded
    Three-Bucket Rearrangement With Constant Extra Space

    Tests in-place three-way partitioning of an array holding only 0, 1 and 2 using constant extra space and a single linear pass, with careful pointer invariants.

    Arrays & Hashingtwo-pointersin-placepartitioningsorting
  • Arrays & HashingMediumAuto-graded
    Repeat Visitors Across UTC Days in an Event Feed

    Normalize ISO 8601 timestamps to UTC dates and use hashing to find users active on at least two distinct UTC calendar days.

    Arrays & Hashinghashingdatetimetimezonelogs
  • Arrays & HashingMediumAuto-graded
    Longest Daily Purchase Streak for Each Customer

    Group purchase records by customer, collapse same-day duplicates, and find the longest run of back-to-back calendar days, reporting results sorted by customer id.

    Arrays & Hashinghashingsortingdatesgaps-and-islands
  • Arrays & HashingMediumAuto-graded
    Distinct Value Foursomes Hitting a Target Total

    Find every distinct set of four values, taken from different positions, that add up to a target, with no repeated value combinations in the output.

    Arrays & Hashingtwo-pointerssortingdeduplicationk-sum
  • Arrays & HashingEasyAuto-graded
    Count Shoppers With Visits on Two or More Days

    Group log entries by person and ignore repeats on the same day, then count how many people appear on at least two different calendar days.

    Arrays & Hashinghash-sethash-mapgroupingdeduplication
  • Arrays & HashingMediumAuto-graded
    Cascading Tile Crush on a Grid

    Simulate a tile-crush game: mark all runs of 3+ equal tiles, clear them, drop tiles with gravity, and repeat until stable, counting removed tiles.

    Arrays & Hashingsimulationmatrixtwo-pointersgrid
  • Arrays & HashingMediumAuto-graded
    Zigzag Parity Check on Subarray Ranges

    Answer many range queries asking whether neighbors in a subarray always differ in odd/even parity, using prefix counts of same-parity adjacent pairs.

    Arrays & Hashingprefix-sumrange-queriesparityarrays
  • Arrays & HashingEasyAuto-graded
    Word-Count Cosine Score for Two Text Strings

    Compute the cosine of the angle between the word-frequency vectors of two strings, using a hash-map counter and guarding against empty inputs.

    Arrays & Hashinghash-mapcountingstringsmath
  • Arrays & HashingMediumAuto-graded
    Count Squares Spanned by Crossing Vertical and Horizontal Segments

    Count axis-aligned squares whose four corners all lie where a vertical segment meets a horizontal one, using per-row bitmasks and pairwise row comparison.

    Arrays & Hashinggeometrybitmaskhashingenumeration
  • Arrays & HashingMediumAuto-graded
    Check Whether Two Custom Dice Give a Flat Sum Distribution

    Decide whether two lists of die-face labels make every total from 1 to 12 appear exactly three times across all 36 face pairings, using pair counting.

    Arrays & Hashingcountinghash-mapenumerationprobability
  • Arrays & HashingEasyAuto-graded
    Group Identical Files by Content from an In-Memory Listing

    Group file entries that have identical byte content, using content length as a cheap first filter, and return only groups of two or more paths in a specified order.

    Arrays & Hashinghashinggroupingstringssimulation
  • Arrays & HashingMediumAuto-graded
    Tally Contiguous Segments Matching a Goal Total

    Count contiguous non-empty segments of an integer array whose sum equals a goal, using running totals and a frequency map to handle negatives and zeros in linear time.

    Arrays & Hashingprefix-sumhash-mapsubarraycounting