KatInterview

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

Arrays & Hashing Interview Problems

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

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 91–120 of 435 results

  • Arrays & HashingEasyAuto-graded
    Find All Top-Frequency Labels Without Using max()

    Count items by their string form and return every label tied for the highest count, in first-appearance order, without calling max().

    Arrays & Hashinghash-mapcountingfrequencyties
  • Arrays & HashingMediumAuto-graded
    Possible Minimum Excluded Values After One Increment

    Find all possible values of the minimum non-negative excluded integer (MEX) achievable after at most one element increment.

    Arrays & Hashingarrayshash-tablefrequency-arraymath
  • Arrays & HashingMediumAuto-graded
    Waiting-Time Triangle Density: Normalize and Evaluate the CDF

    Normalize a piecewise-linear triangular density to find its constant, then evaluate the resulting piecewise-quadratic cumulative distribution at a list of query points.

    Arrays & Hashingprobabilitycdfpiecewise-functionsintegration
  • Arrays & HashingEasyAuto-graded
    Repair a Sensor Log: Merge, Sort, and Interpolate Gaps

    Merge duplicate timestamps by averaging known readings, sort, then fill missing values by linear interpolation inside gaps and nearest-value holding at the ends.

    Arrays & Hashinghash-mapsortinginterpolationtime-series
  • Arrays & HashingEasyAuto-graded
    Pair Sum Existence Check in an Integer List

    Decide whether any two elements at different positions in an integer list add up to a given value, testing hash-set lookups and careful handling of duplicates.

    Arrays & Hashinghash-settwo-sumarrayscomplement
  • Arrays & HashingMediumAuto-graded
    Prefix Value Blocks in a Shuffled Sequence

    Decide, for every k, whether the values 1..k occupy a contiguous block of a permutation, using value positions and a running span instead of scanning subarrays.

    Arrays & Hashingpermutationindex-mappingrunning-min-maxstring-output
  • Arrays & HashingMediumAuto-graded
    Quarter-Turn a Square Grid of Pixels Without Extra Storage

    Turn a square integer grid a quarter turn clockwise by modifying it in place, testing index mapping and in-place transforms such as transpose plus row reversal.

    Arrays & Hashingmatrixin-placesimulationtranspose
  • Arrays & HashingEasyAuto-graded
    Find Lowest Cost Ticket Pair Across Consecutive Days

    Find the minimum combined cost of an outbound and return ticket where return happens strictly after departure.

    Arrays & Hashingarraysgreedyprefix-minimum
  • Arrays & HashingMediumAuto-graded
    Users Active for a Week Straight: Detect 7-Day Streaks in Event Logs

    Find users whose event log contains at least seven consecutive UTC calendar days of activity, using per-user day deduplication and a sorted streak scan.

    Arrays & Hashinghashingdatesstreakssorting
  • Arrays & HashingEasyAuto-graded
    Calculate Maximum Single-Trade Return

    Find the maximum non-negative profit from purchasing an asset on one day and selling it on a subsequent day.

    Arrays & Hashingarraysdynamic-programminggreedy-intervals
  • Arrays & HashingEasyAuto-graded
    Cross-Tabulate Records by Composite Row and Column Keys

    Group records by composite row and column keys, sum a value field per pair, and return the axes in first-seen order with a dense grid that has zeros for missing pairs.

    Arrays & Hashinghash-mapgroupingaggregationtuples
  • Arrays & HashingMediumAuto-graded
    Gravity Grid: Pushing Tokens Up from Below and Spotting Matching Lines

    Simulate a grid where tokens are pushed in from the bottom of a column, and after each push report success and whether any full column or full row is single-typed.

    Arrays & Hashingsimulationmatrixstate-trackinggrid
  • Arrays & HashingEasyAuto-graded
    Check Loan Records for Proper Borrow-Return Order

    Scan a time-ordered list of library events and verify each item's history strictly alternates borrow, return, starting with a borrow, using per-item state tracking.

    Arrays & Hashinghash-setstate-trackingsimulationvalidation
  • Arrays & HashingEasyAuto-graded
    Smallest Axis-Aligned Box Around Scattered Points

    Scan a list of integer 2D points once to find the extreme x and y values, then report the enclosing axis-aligned box as a corner plus width and height.

    Arrays & Hashingarraysgeometrymin-maxsingle-pass
  • Arrays & HashingEasyAuto-graded
    Calculate Spend Percentage of High-Volume Spenders

    Compute the share of 2023 total expenditure contributed by users who met a high-tier spending threshold in 2022.

    Arrays & Hashingarrayshash tabledata manipulationcohort analysis
  • Arrays & HashingEasyAuto-graded
    Uncovered Integer Gaps Within a Closed Window

    Scan a sorted list of distinct integers once to report every maximal run of integers in a closed window that the list skips, formatting single gaps as one-element lists.

    Arrays & Hashingarraysintervalstwo-pointersedge-cases
  • Arrays & HashingMediumAuto-graded
    Validate a Shuffled Start/Stop Service Log for Each Component

    Replay timestamped start/stop events in time order, with ties broken by input position, tracking one active job per category, and confirm the log is valid and fully closed.

    Arrays & Hashinghash-setsortingsimulationstate-tracking
  • Arrays & HashingMediumAuto-graded
    Detect Target Pair in Spiral Matrix Order

    Determine if two distinct cells in a 2D matrix sum to a target integer while processing elements in spiral order.

    Arrays & Hashingarrayshash-tablematrix
  • Arrays & HashingMediumAuto-graded
    Count Disjoint Pairs That Add Up to a Goal Value

    Find the most disjoint pairs in an integer list whose sum equals a goal, using value counts or sorting with two pointers, while handling duplicates, negatives and the half-goal case.

    Arrays & Hashinghash-maptwo-pointersgreedycounting
  • Arrays & HashingMediumAuto-graded
    Count Maximum Disjoint Pairs Summing to a Target

    Find the most index-disjoint pairs in an integer array whose values add up to a target, testing hashing of complements, counting, and handling of the self-pairing case.

    Arrays & Hashinghash-mapcountingtwo-pointersgreedy
  • Arrays & HashingMediumAuto-graded
    Closest Bakery Stall for Every Shopper on a Street

    For each shopper on a line, find the closest stall index, with ties going to the lower index, testing two-sided linear scans for nearest-neighbor lookups.

    Arrays & Hashingarraystwo-pointersprefix-suffixnearest-neighbor
  • Arrays & HashingMediumAuto-graded
    Count Index Pairs With a Fixed Value Gap

    Count index pairs i < j whose values differ by exactly k, using a frequency map and handling the k = 0 case separately to avoid double counting.

    Arrays & Hashinghash-mapcountingfrequencypairs
  • Arrays & HashingMediumAuto-graded
    Collapse Rapid Cart Adds into Daily Pacific Action Counts

    Filter add-to-cart events, convert UTC to Pacific dates, merge rapid repeats into single actions with a chained gap rule, and count the actions per user, date and SKU.

    Arrays & Hashinghashinggroupingdatetimetimezones
  • Arrays & HashingEasyAuto-graded
    Find the Maximum Value in a Large Numerical Stream

    Find the maximum integer in a sequence while accounting for empty inputs and signed values.

    Arrays & Hashingarraysstreamingbasics
  • Arrays & HashingEasyAuto-graded
    Identify Redundant Files by Content Matching

    Cluster files that share identical byte contents by filtering first on file size metadata and then hashing content.

    Arrays & Hashingarrayshash mapstrings
  • Arrays & HashingMediumAuto-graded
    Peel a Grid Layer by Layer in a Clockwise Spiral

    Flatten a rectangular grid into a list by walking its perimeter clockwise inward, using shrinking boundaries and guards so single leftover rows or columns are not read twice.

    Arrays & Hashingmatrixsimulationtwo-pointersspiral
  • Arrays & HashingMediumAuto-graded
    Cohort Return Rates by Months Since First Visit

    Group users by the month of their first activity, then compute the fraction of each cohort that was active in every later month offset, using calendar-month arithmetic.

    Arrays & Hashinghash-mapgroupingdatescohort-analysis
  • Arrays & HashingMediumAuto-graded
    Apply a Single Capture Move on a Two-Colour Grid

    Apply one move on a grid: validate the target cell, find enclosed opponent runs in eight directions, and flip them together, or return the grid unchanged if no capture is possible.

    Arrays & Hashinggridsimulationmatrixdirections
  • Arrays & HashingEasyAuto-graded
    Weekly Trailing Mean Over a Daily Usage Series

    Compute the mean of every full block of seven consecutive readings in a list, returning an empty list when fewer than seven readings exist; tests sliding-window technique.

    Arrays & Hashingsliding-windowarraysprefix-sumsnumerics
  • Arrays & HashingEasyAuto-graded
    Order Each Neighboring Couple in a List, Skipping a Lone Tail

    Reorder the two values inside every consecutive couple of a list so the smaller comes first, keeping couples in place and leaving an unpaired final value alone.

    Arrays & Hashingarraystwo-pointerssimulationindex-handling