KatInterview

Topic

Arrays & Hashing interview problems

Two pointers, prefix sums, hash maps and sliding windows. 477 original problems, each with hidden test cases you can run in the browser.

Problems477

137 easy303 medium37 hard

Showing 181–210 of 477 results

  • Find the longest contiguous run in an integer list (negatives and zeros allowed) whose total equals a target, using prefix sums and a hash map of earliest positions.

    Auto-gradedprefix-sumhash-mapsubarray
  • Find every possible smallest-missing value of an array after at most one capped +1 edit, using counting and MEX case analysis in linear time.

    Auto-gradedmexcountingcase-analysisfrequency-array
  • Scan a 9x9 digit grid once and decide whether any row, column, or 3x3 block repeats a digit, using per-group bitmasks or sets.

    Auto-gradedhashingbitmaskmatrixsimulation
  • Find the largest k such that at least k scores are k or higher, using counting with capped values to reach linear time.

    Auto-gradedcountingh-indexbucketarrays
  • Match reply events to earlier directed invites, normalize each user pair, and keep the earliest valid reply date per pair, sorted by pair.

    Auto-gradedhash-mapgroupingdeduplicationdates
  • Find the two products that appear together in the most orders, handling duplicate lines, mirrored pairs, ties, and orders with fewer than two distinct products.

    Auto-gradedhash-mapcombinationscountinggrouping
  • 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.

    Model answerarrayssimulationgridoptimization
  • Parse comma-separated payment rows, build a per-row rate from several rules plus a per-merchant running total, and round fees exactly to whole cents.

    Auto-gradedhash-mapparsingsimulationrounding
  • Sliding-window distinct counting per group: find callers who reach at least five different receivers within any 7-day span of their call log.

    Auto-gradedsliding-windowhash-mapgroupingtimestamps
  • Aggregate daily purchase metrics from event logs and reconcile two event snapshots against a ledger to judge whether a tracking fix worked, using hash-map grouping.

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

    Model answerarrayssimulationmatrixhash-table
  • Count how many booking records each vehicle has and return the ID with the highest count, breaking ties by the smallest ID.

    Auto-gradedhash-mapcountingtie-breaking
  • Compute the inner product of two sparse vectors given as sorted index-value pairs by intersecting their indices with a linear merge, without building dense arrays.

    Auto-gradedtwo-pointerssparse-vectorsorted-mergesimulation
  • Simulate a custom board game involving stack placing and directed toppling moves to determine the game outcome.

    Model answerarrayssimulationmatrix
  • Clean a noisy ranked result list (missing, duplicated, unknown, or oversized) and compute precision and recall against ground-truth labels.

    Auto-gradedhashingsetsmetricsinput-validation
  • Group activity logs by user, dedupe dates, find maximal consecutive-day runs of length 7 or more, and report each user's earliest such run.

    Auto-gradedhashingdatesgaps-and-islandssorting
  • Group booking records by user, find each canceller's earliest cancellation, and compute the percentage with no later confirmed or returned booking.

    Auto-gradedhash-maptimestampsgroupingpercentage
  • Count labels in every third slot of a flat list, find the second-highest distinct count, and break ties by earliest appearance.

    Auto-gradedhash-mapcountingfrequencytie-breaking
  • Find two different positions in an integer list whose values sum to a goal, using a deterministic tie-break rule, which tests complement lookup with a hash map.

    Auto-gradedhash-maparraycomplement-lookuptwo-sum
  • Tests normalizing undirected pairs, filtering pending rows, and keeping the earliest date per pair from a list of event dictionaries, with deterministic sorted output.

    Auto-gradedhash-mapgroupingnormalizationsorting
  • 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.

    Model answerparsingmoney-arithmeticextensible-designsorting
  • Simulate a year of account activity, applying a flat monthly charge unless a month has enough payments with a large enough total, and return the final balance.

    Auto-gradedsimulationhash-mapaggregationconditional-logic
  • Rank five-card hands with a tuple key, then decide whether an outcome is forced across all ways to fill in missing cards.

    Auto-gradedsimulationcombinatoricscountingtie-breaking
  • Combines a binary search on a sorted list, adding one to a digit-array number with carry, and a stable in-place move of zeros to the back.

    Auto-gradedbinary-searchtwo-pointerscarryin-place
  • Group event logs by session, sort chronologically, count adjacent front-then-rear transitions, and average over all sessions, including sessions with zero flips.

    Auto-gradedhash-mapgroupingsortingsimulation
  • 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.

    Model answerdata-normalizationhash-mapsevaluation-metricsprecision-recall
  • Find the earliest entry in a list of strings that occurs exactly once overall, or return an empty string, testing frequency counting combined with preserved order.

    Auto-gradedhash-mapcountingstringstwo-pass
  • Find the single pair of distinct positions in an integer list whose values add up to a goal, using a one-pass lookup instead of checking every pair.

    Auto-gradedhash-maparraycomplement-lookup
  • Tests group-then-broadcast logic: compute each group's mean over a list of dict records, then attach each row's difference from its group mean while preserving order.

    Auto-gradedhash-mapgroup-byaggregationsimulation
  • Apply an ordered list of named filter rules to every user-event pair and build a per-user list of qualifying event ids, handling missing prices, empty rule lists and unknown rule names.

    Auto-gradedhash-mapsimulationfilteringstrategy-pattern

More topics