Topic
Arrays & Hashing interview problems
Two pointers, prefix sums, hash maps and sliding windows. 474 original problems, each with hidden test cases you can run in the browser.
134 easy303 medium37 hard
Showing 1–30 of 474 results
Find the shortest contiguous slice of an integer list containing exactly k different values, using a sliding window with frequency counts.
Auto-gradedsliding-windowhash-mapsubarraytwo-pointersDecide whether an ordered list of argument types fits any function in a catalog, given required, trailing optional, and variadic parameters with exact type matching.
Auto-gradedsimulationarray-scanningsignature-matchingedge-casesFind the minimum length of a contiguous subarray containing at least K unique elements using a sliding window.
Auto-gradedsliding-windowtwo-pointershash-tablearraysDetermine the maximum possible gain achieved by completing at most one purchase and sale transaction over a sequence of prices.
Auto-gradedarraysgreedyprefix-minimumBuild an array where each entry is the product of all other entries, without division, in linear time, using prefix and suffix running products.
Auto-gradedprefix-productsuffix-productarrayin-placeReplay 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.
Auto-gradedsimulationcountingmatrixdiagonalsScan an integer list and return the indices of elements strictly larger than every neighbor that exists, handling the ends, plateaus, and tiny inputs correctly.
Auto-gradedarraystraversalboundary-conditionsFind 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.
Auto-gradedprefix-sumsbinary-searchsliding-windowinterpolationScan 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.
Auto-gradedarrayscanboundary-conditionsstrict-comparisonSimulate 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.
Auto-gradedsimulationmatrixtwo-pointersgridGiven 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.
Auto-gradedhashinggeometrygrid-bucketingsimulationScan 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.
Auto-gradedarrayssliding-windowtwo-pointerslinear-scanGroup 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.
Auto-gradedhash-mapdatesaggregationcohort-analysisImplement weighted index sampling with binary search and an exclusion product array without division in O(1) auxiliary space.
Model answerarraysbinary-searchprefix-sumProcess a stream of possibly redelivered payment events and compute final account balances by applying each unique event ID only once.
Auto-gradedhash-sethash-mapdeduplicationsimulationSum the shortest arc distances between consecutive stops on a ring with weighted edges, using prefix sums for O(1) arc queries.
Auto-gradedprefix-sumcircular-arraysimulationProcess website activity logs to compute chronological 3-site visit subsequences and find the most widely performed pattern across unique users.
Auto-gradedarrayshash-tablesortingsubsequenceCount 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.
Auto-gradedhash-mapcountingsortingco-occurrenceTests 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.
Auto-gradedtwo-pointersin-placepartitioningsortingNormalize ISO 8601 timestamps to UTC dates and use hashing to find users active on at least two distinct UTC calendar days.
Auto-gradedhashingdatetimetimezonelogsGroup 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.
Auto-gradedhashingsortingdatesgaps-and-islandsFind every distinct set of four values, taken from different positions, that add up to a target, with no repeated value combinations in the output.
Auto-gradedtwo-pointerssortingdeduplicationk-sumGroup log entries by person and ignore repeats on the same day, then count how many people appear on at least two different calendar days.
Auto-gradedhash-sethash-mapgroupingdeduplicationSimulate a tile-crush game: mark all runs of 3+ equal tiles, clear them, drop tiles with gravity, and repeat until stable, counting removed tiles.
Auto-gradedsimulationmatrixtwo-pointersgridAnswer many range queries asking whether neighbors in a subarray always differ in odd/even parity, using prefix counts of same-parity adjacent pairs.
Auto-gradedprefix-sumrange-queriesparityarraysCompute the cosine of the angle between the word-frequency vectors of two strings, using a hash-map counter and guarding against empty inputs.
Auto-gradedhash-mapcountingstringsmathCount axis-aligned squares whose four corners all lie where a vertical segment meets a horizontal one, using per-row bitmasks and pairwise row comparison.
Auto-gradedgeometrybitmaskhashingenumerationDecide 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.
Auto-gradedcountinghash-mapenumerationprobabilityGroup 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.
Auto-gradedhashinggroupingstringssimulationCount 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