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 61–90 of 475 results
Evaluate posterior coin probabilities, posterior predictive likelihoods, and expected stopping times following observed heads.
Auto-gradedprobabilitybayes-theoremexpected-valuebayesian-inferenceFind the longest contiguous strictly increasing window in an integer array after replacing at most one element with any integer, using prefix and suffix run lengths.
Auto-gradedarrayssliding-windowprefix-suffixdynamic-programmingGroup timestamped events by user, order them in time, and count how many distinct users share each opening action sequence of length up to k.
Auto-gradedhash-mapgroupingsortingprefixesShift an integer array left or right by k using modular arithmetic, then locate every occurrence of one or more keywords in a simple CSV string, reporting row, column and offset in the cell.
Model answerarray-rotationmodular-arithmeticstring-searchcsv-parsingNormalize directed city pairs into unordered ones, remove duplicates, and return them in sorted order, testing canonicalization with hashing and sorting.
Auto-gradedhashingsortingdeduplicationcanonical-formNormalize IPv4/IPv6 strings, skip invalid ones, count occurrences, and return the top ten addresses while keeping every address tied at the tenth-place frequency.
Auto-gradedhash-mapcountingsortingstring-parsingSimulate a clockwise inward walk over a grid with obstacle cells, turning on edges, obstacles and visited cells, and stopping when every direction is closed.
Auto-gradedmatrixsimulationspiralgridFind the maximum gain possible from buying and selling a stock once, given a sequence of daily values.
Auto-gradedarraysgreedydynamic-programmingCount subarrays where the number of elements congruent to a residue, taken modulo the same base, equals that residue, using prefix remainders and a frequency table.
Auto-gradedprefix-sumhash-mapmodular-arithmeticsubarraysGroup users by first-activity month and compute the share who return exactly 30 days later, excluding users whose day 30 lies beyond the last observed date.
Auto-gradedhash-mapdatescohort-analysisgroupingCombine three closed-form statistics results: the lowest shared correlation of three variables, a reverse regression slope from R² and a slope, and the covariance of the max and min of two uniforms.
Auto-gradedcorrelationlinear-regressionorder-statisticscovarianceFind the largest total of any k consecutive values in a list, testing fixed-size sliding window technique and the ability to avoid recomputing overlapping sums.
Auto-gradedsliding-windowarraysprefix-sumFind the longest stretch of 1s achievable in a binary list when at most one 0 may be changed to 1, using a two-pointer window that tolerates one zero.
Auto-gradedsliding-windowtwo-pointersbinary-arrayPerform quantitative financial modeling and sensitivity analysis for renewable energy pilot projects.
Auto-gradedfinancesensitivity-analysismathstatisticsReturn the next-success probability under independence, plus a pooled two-proportion z statistic and two-sided p-value comparing two success rates.
Auto-gradedhypothesis-testingtwo-proportion-z-testconditional-probabilitynormal-distributionSimulate placing fixed binary shapes onto a grid at the first row-major position where their filled cells hit only empty cells, labelling each by its index.
Auto-gradedsimulationmatrixgridbrute-forceCount contiguous non-empty subarrays whose elements sum to a goal value, using running prefix sums with a frequency map to handle negatives and zeros in linear time.
Auto-gradedprefix-sumhash-mapsubarraycountingFind the minimum length of a contiguous block of an integer list containing at least k different values, using a sliding window with a frequency map.
Auto-gradedsliding-windowtwo-pointershash-mapConvert a flat list of throws into a ten-frame total, applying look-ahead bonuses for strikes and spares, including fill throws in the last frame.
Auto-gradedsimulationarraylook-aheadpointer-walkTests using a hash-based structure to drop repeated values from a list while keeping first-occurrence order, in linear time and without modifying the input.
Auto-gradedhash-setordered-dictarraysdeduplicationBuild a service that checks a city's latitude, pulls a 72-hour forecast from an unreliable API with proper retries, and returns every 8-hour span of strictly falling, gapless hourly temperatures.
Model answersliding-windowretry-backoffapi-integrationerror-handlingTests hashing and counting over text: tokenize, compute smoothed IDF for query terms, score every document, and sort by descending score with an index tie-break.
Auto-gradedhashingtf-idftokenizationsortingSimulate an in-memory key-value dictionary given a sequence of insertion, lookup, and deletion instructions.
Auto-gradedarrayshash-mapdata-structuresdesignParse a JSON list of account records with exact decimal arithmetic, drop invalid rows, keep the newest record per account, and report a rounded total plus a per-account map.
Model answerpythonjsondecimaldeduplicationConcatenate truncated token lists into equal-length blocks, zero-pad the last one, and build a parallel 0/1 mask marking real tokens versus padding.
Auto-gradedarrayssimulationtwo-pointersbatchingCluster words that share identical letter counts into ordered buckets, using a hashable frequency key rather than sorting each word's letters, while preserving duplicates and order.
Auto-gradedhash-mapstringsanagramsfrequency-countFilter streaming events by duration and date window, count plays per track, and produce a global top 5 and per-country top 3 with deterministic tie-breaking.
Auto-gradedhash-mapcountingsortinggroupingTests using a hash set alongside a list to filter repeated integers in one pass while preserving first-appearance order, in linear time.
Auto-gradedhash-setarraysdeduplicationorder-preservationPair sign-in and sign-out events per user from an unsorted log using chronological order and FIFO matching, and report users with a session within a time limit.
Auto-gradedhash-mapsortingqueuesimulationSimulate k-means++ seeding with a fixed RNG protocol, then run two assign/update rounds and report clusters, centroids and final squared error.
Auto-gradedsimulationclusteringrandomized-samplingfloating-point