KatInterview

Topic

Arrays & Hashing interview problems

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

Problems475

135 easy303 medium37 hard

Showing 31–60 of 475 results

  • 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.

    Auto-gradedprefix-sumhash-mapsubarraycounting
  • Process a series of insertion, update, and deletion instructions on a key-value store and return the final contents ordered by key.

    Auto-gradedarraysstringshash-table
  • Find the smallest absolute gap between any two readings, then list every strictly increasing pair achieving it, handling duplicates correctly. Tests sorting and adjacent-gap reasoning.

    Auto-gradedsortingarraysadjacent-differenceedge-cases
  • Filter a word list to the entries whose letter multiset is shared by at least two entries, keeping input order and duplicates, using letter-count keys.

    Auto-gradedhash-mapanagramscountingstrings
  • Filter a list of allocated block addresses to those absent from a list of live pointers, keeping the original order, using hash-set membership for linear-time performance.

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

    Model answerbacktrackingpruningdeduplicationsubsets
  • Build the Cartesian product of named option lists into a list of dictionaries, handling empty inputs and a defined output order.

    Auto-gradedcartesian-productbacktrackingitertoolsdictionaries
  • Group order records by customer and count how many fall into each requested status, producing one sorted, zero-filled row per customer.

    Auto-gradedhash-mapgroupingcountingsorting
  • Find the best sum over a contiguous run of position-sorted items, limited by item count and coordinate span, using sorting and a two-pointer sweep.

    Auto-gradedsliding-windowtwo-pointerssortingprefix-sums
  • Filter a list of source file records against destination records using readability, writability, size and timestamp rules, returning names in source order.

    Auto-gradedhash-mapfilteringsimulation
  • Tests filtering an event log by type, grouping by date, counting distinct ids with sets, and returning date-sorted results while omitting dates that have no qualifying events.

    Auto-gradedhash-mapsetgroupingsorting
  • Compute a token's final cell on a grid with blocked cells when its heading changes at given timestamps up to 10^9, which requires processing time segments instead of simulating each tick.

    Auto-gradedsimulationgridintervalslarge-input
  • Slide a square window over an integer grid with a given step, and report each window's maximum with its grid coordinates, resolving ties by the smallest row, then the smallest column.

    Auto-gradedmatrixsliding-windowsimulationtie-breaking
  • Count past coupon redemptions per (user, coupon) pair from a log, then answer many read-only queries on whether each user is still under the coupon's cap.

    Auto-gradedhash-mapcountingaggregationcomposite-key
  • Find the pair of indices whose values sum to a target, choosing the pair that finishes earliest in the array, with deterministic duplicate handling, using a one-pass hash map.

    Auto-gradedhash-maptwo-sumduplicatesone-pass
  • Compute the mean of a list of numbers while skipping None and NaN entries, returning 0.0 when nothing valid remains and rounding to two decimals.

    Auto-gradedarraysdata-cleaningnan-handlingaggregation
  • Partition a list of lowercase words into buckets of mutual rearrangements, using a canonical key and a hash map while keeping a deterministic output order.

    Auto-gradedhash-mapstringssortinggrouping
  • Filter a list of event records by type, time window and id, then order them stably by timestamp and truncate, testing careful handling of optional arguments and ties.

    Auto-gradedhashingstable-sortfilteringdedupe
  • Find the final bits on a ring after several togglers walk clockwise for k steps, using lap decomposition, parity, and a cyclic difference array.

    Auto-gradeddifference-arraymodular-arithmeticparitysimulation-optimization
  • Combine a threshold binary search with greedy arithmetic sums, a linear scan counting subarrays with exact min and max, and hashing of binary rows to count identical pairs.

    Auto-gradedbinary-searchgreedysliding-windowhashing
  • Given a permutation of 1..N, decide for each k whether the values 1..k occupy a contiguous block of positions, using a running min/max position sweep.

    Auto-gradedpermutationarrayssweepmin-max
  • Tests hash-map indexing of duplicate values to list every index pair i < j whose values sum to a goal, in a specific sorted output order.

    Auto-gradedhash-maptwo-sumduplicatesenumeration
  • Aggregate (shopper, date, amount) records into per-shopper totals for a 7-day window, using hand-written ISO date stepping and hashing instead of date libraries.

    Auto-gradedhashingaggregationstring-datessimulation
  • Aggregate a list of search log records into funnel, quality, latency and repeat-usage metrics, handling empty input and even-length medians.

    Auto-gradedhash-mapaggregationsimulationmedian
  • Compute a 95% z-based confidence interval for a population mean from a sample mean, known population standard deviation, and sample size, using the standard error.

    Auto-gradedconfidence-intervalcentral-limit-theoremstandard-errora-b-testing
  • Group file paths whose contents are identical, using cheap filters like size and digest, with an exact comparison to confirm. Output is sorted groups of two or more paths.

    Auto-gradedhashinggroupingstringssorting
  • Return the items of one string list whose trimmed, lowercased form is missing from a second list, keeping original spelling, order, and duplicates; tests hash sets and normalization.

    Auto-gradedhash-setstringsnormalizationfiltering
  • Find the longest contiguous stretch of an integer array containing at most two distinct values, testing sliding window and frequency tracking.

    Auto-gradedsliding-windowtwo-pointershash-map
  • Find the maximum size of two matching arrays derived by repeatedly combining adjacent elements from two positive integer sequences, or return -1 if impossible.

    Auto-gradedarrayshash-tabletwo-pointersprefix-sum
  • Convert longitude-first route points into a map request with start and end markers and path groups of ten segments that alternate colors and share boundary points.

    Auto-gradedarraysgroupingtransformationdictionaries

More topics