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.
135 easy303 medium37 hard
Showing 91–120 of 475 results
Find the length of the longest contiguous stretch of an integer array in which no value appears twice, using a sliding window with a last-seen index map.
Auto-gradedsliding-windowhash-maptwo-pointerssubarrayDebug a small spending-limit module with failing tests: find root causes, fix them, add minimal regression tests, and explain your debugging process and tools.
Model answerdebuggingunit-testingroot-cause-analysisfloating-pointCompute, for every empty cell, the gap to the nearest blocker in each of four directions using linear sweeps, then return the cells whose four gaps equal a given target.
Auto-gradedgridmatrixprefix-sweepsimulationProcess sequential database schema snapshots to assign permanent, case-insensitive unique column aliases with automatic collision resolution.
Auto-gradedarraysstringsdesign-dsFilter a list of record dictionaries so only the first record for each identifier remains, preserving order and doing it in a single linear pass with a hash set.
Auto-gradedhash-setdeduplicationarraysorder-preservationFinds all unique value triplets in an integer array that sum to a specified target using sorting, two-pointer scanning, and pruning.
Auto-gradedarraystwo-pointerssortingdeduplicationCount items by their string form and return every label tied for the highest count, in first-appearance order, without calling max().
Auto-gradedhash-mapcountingfrequencytiesFind all possible values of the minimum non-negative excluded integer (MEX) achievable after at most one element increment.
Auto-gradedarrayshash-tablefrequency-arraymathGiven a batch of 2D routes, compute for each waypoint the length of the remaining route to the final waypoint, in linear time, handling short and empty inputs.
Model answersuffix-sumnumpyvectorizationeuclidean-distanceNormalize a piecewise-linear triangular density to find its constant, then evaluate the resulting piecewise-quadratic cumulative distribution at a list of query points.
Auto-gradedprobabilitycdfpiecewise-functionsintegrationMerge duplicate timestamps by averaging known readings, sort, then fill missing values by linear interpolation inside gaps and nearest-value holding at the ends.
Auto-gradedhash-mapsortinginterpolationtime-seriesDecide 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.
Auto-gradedhash-settwo-sumarrayscomplementDecide, 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.
Auto-gradedpermutationindex-mappingrunning-min-maxstring-outputTurn 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.
Auto-gradedmatrixin-placesimulationtransposeFind the minimum combined cost of an outbound and return ticket where return happens strictly after departure.
Auto-gradedarraysgreedyprefix-minimumFind users whose event log contains at least seven consecutive UTC calendar days of activity, using per-user day deduplication and a sorted streak scan.
Auto-gradedhashingdatesstreakssortingFind the maximum non-negative profit from purchasing an asset on one day and selling it on a subsequent day.
Auto-gradedarraysdynamic-programminggreedy-intervalsGroup 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.
Auto-gradedhash-mapgroupingaggregationtuplesSimulate 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.
Auto-gradedsimulationmatrixstate-trackinggridScan 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.
Auto-gradedhash-setstate-trackingsimulationvalidationScan 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.
Auto-gradedarraysgeometrymin-maxsingle-passCompute the share of 2023 total expenditure contributed by users who met a high-tier spending threshold in 2022.
Auto-gradedarrayshash tabledata manipulationcohort analysisScan 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.
Auto-gradedarraysintervalstwo-pointersedge-casesReplay 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.
Auto-gradedhash-setsortingsimulationstate-trackingDetermine if two distinct cells in a 2D matrix sum to a target integer while processing elements in spiral order.
Auto-gradedarrayshash-tablematrixFind 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.
Auto-gradedhash-maptwo-pointersgreedycountingFind 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.
Auto-gradedhash-mapcountingtwo-pointersgreedyFor 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.
Auto-gradedarraystwo-pointersprefix-suffixnearest-neighborCount 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.
Auto-gradedhash-mapcountingfrequencypairsFilter 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.
Auto-gradedhashinggroupingdatetimetimezones