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 121–150 of 475 results
Find the most profitable buy-then-sell pair in a price array when the sale must happen within D days of the purchase, in O(n) time and O(1) extra space.
Model answersliding-windowblock-decompositionmonotonic-dequestock-tradingFind the maximum integer in a sequence while accounting for empty inputs and signed values.
Auto-gradedarraysstreamingbasicsCluster files that share identical byte contents by filtering first on file size metadata and then hashing content.
Auto-gradedarrayshash mapstringsFlatten 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.
Auto-gradedmatrixsimulationtwo-pointersspiralGroup 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.
Auto-gradedhash-mapgroupingdatescohort-analysisApply 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.
Auto-gradedgridsimulationmatrixdirectionsCompute 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.
Auto-gradedsliding-windowarraysprefix-sumsnumericsReorder 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.
Auto-gradedarraystwo-pointerssimulationindex-handlingCompute the 2D cross-correlation between a grid matrix and a filter kernel using valid padding and stride 1.
Auto-gradedarraysmatrixReturn theoretical properties and compute the expected value and variance for a Binomial random variable given sample size n and success probability p.
Auto-gradedbinomialprobabilitystatisticsmathReturn the k most frequent values in an integer list, ordered by count and then by first appearance, using hash counting and frequency buckets for linear time.
Auto-gradedhash-mapbucket-sortfrequency-counttop-kMap each marked grid cell to the sorted top-left corners of all in-bounds 2x2 windows that contain it, testing coordinate arithmetic and bounds handling.
Auto-gradedgridhash-mapcoordinatesenumerationValidate a nested vendor response with strict type checks, then apply ordered business rules to return the first failing reason code.
Auto-gradedvalidationhash-maptype-checkingsimulationRearrange an array in place into its next lexicographic ordering, and evaluate a parenthesis-free arithmetic string with truncating division, both in linear time.
Auto-gradednext-permutationtwo-pointersexpression-parsingin-placeExplain what three short pandas helper functions do, then propose and justify improvements to their correctness, speed, readability, robustness and testability.
Model answerpythonpandascode-reviewvectorizationCompute the dot product of two run-length encoded integer vectors by walking both run lists together, without expanding them into full arrays.
Auto-gradedtwo-pointersrun-length-encodingsimulationCompute the expected value and total variance of the combined sum of two random variables given their individual means, variances, and covariance.
Auto-gradedstatisticsprobabilitymathMatch call argument types against registered signatures, some with a trailing repeatable parameter, and return the sorted names of every signature that fits each call.
Auto-gradedhashingstringsvariadic-matchingprefix-keysProcess an array of decimal digits representing a non-negative integer by adding one, correctly handling carry propagation and list expansion.
Auto-gradedarraysmath-bitseasyScan sorted timestamped sensor readings once and group consecutive readings strictly above a cutoff into [first_time, last_time] windows.
Auto-gradedarraystwo-pointersintervalssimulationSimulate a synchronous grid disease model with delayed death or recovery, then try every single-row or single-column firebreak to minimize dead plants.
Auto-gradedsimulationgridbrute-forcecellular-automatonProcess user experiment assignments and ride telemetry data to calculate a Welch's two-sample t-test p-value under strict filtering rules.
Auto-gradedstatisticsdata-processinghypothesis-testingTotal a shopping cart where each coupon discounts one unit of its item, with percent discounts rounded half-to-even in exact integer arithmetic.
Auto-gradedhash-mapsimulationroundinginteger-mathEvaluate post-matching covariate balance by computing the absolute standardized mean difference across features.
Auto-gradedstatisticsmath-bitsarraysAggregate per-group, per-window means from daily records, compute a difference-in-differences estimate, and flag baseline drift between two pre-period sub-windows.
Auto-gradedhashingaggregationstatisticsdate-windowsConstruct all explicit configurations from a dictionary mapping parameter names to lists of candidate values using Cartesian product generation.
Auto-gradedcartesian-productgeneratorarraysdictionary-manipulationFind the pair of set keys with the highest intersection size, using Jaccard similarity and lexicographical order as tie-breakers via an inverted index approach.
Auto-gradedinverted-indexhash-tablearraysstringSimulate a sequence of string commands (row reversal, row swap, 90-degree clockwise turn) on a rectangular grid whose shape changes after each turn.
Auto-gradedmatrixsimulationstring-parsingrotationCompute the product of two mostly-zero integer matrices by precomputing nonzero positions so that no work is spent on zero operands.
Auto-gradedmatrixsparsesimulationhashingCompute the modular product of all elements in an array except the current element for each index without division.
Auto-gradedarraysprefix-summath