practice a little every day — you've got this ♡
Coding Interview Problems
Practice 6043 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.
- 6043
- Problems
- 2238
- Auto-graded
- 15
- Topics
- 274
- Added today
Showing 1531–1560 of 2791 results
- StringsMediumModel answerRepair a Rewards Calculator: Three Red Tests in a Java Service
Diagnose and fix three failing JUnit tests in a Java rewards service by touching at most three files, then explain how to keep similar bugs from coming back.
Stringsjavadebuggingunit-testingjunit - Arrays & HashingMediumAuto-gradedReconcile Payments Against Open Invoices in Three Tiers
Process payments in order, pairing each with an invoice by ID plus amount, then by unique amount, then by closest amount within a percentage tolerance.
Arrays & Hashinghash-mapsimulationmatchingfloating-point - Arrays & HashingEasyAuto-gradedSliding Marble on a Tiltable Grid with Scheduled Tilts
Simulate a marble on a grid whose tilt changes at scheduled times, and find its final cell efficiently when the end time can reach a billion seconds.
Arrays & Hashingsimulationgridtime-segmentstwo-pointers - Arrays & HashingMediumAuto-gradedBest Single Round-Trip Gain Across Tickers in an Unordered Log
Find the largest gain from buying and later selling the same ticker on a strictly later date, given an unsorted log with duplicate dates; tests grouping, sorting and careful running-minimum updates.
Arrays & Hashinghash-mapsortinggreedytime-series - Arrays & HashingEasyAuto-gradedCount Repeated Strings in a Large List
Tests hash-map frequency counting: find every string occurring more than once in a list and report its count, using exact comparison.
Arrays & Hashinghash-mapcountingstringsfrequency - Trees & GraphsMediumAuto-gradedRebuild a Search Tree from Its Preorder Listing
Rebuild a binary search tree from its preorder listing of distinct integers in linear time, then report it in level order with null placeholders. Tests stack-based construction and BFS serialization.
Trees & Graphsbinary-search-treestackpreorderbfs - Stacks & QueuesMediumModel answerPredicting Output Order with the Browser Event Loop
Work out the print order of a short script mixing timers, promises and microtasks, then explain how the browser event loop schedules each kind of task.
Stacks & Queuesjavascriptevent-loopasyncmicrotasks - Data Structure DesignHardModel answerCrash-Safe Job Dispatcher with Lease Timeouts and Dependency Graphs
Build an in-memory job dispatcher where workers hold timed leases, stale workers are fenced off, jobs form a dependency DAG, and you justify the delivery guarantees.
Data Structure Designleasesfencing-tokensdagtopological-sort - Arrays & HashingMediumModel answerRandomly Fill Ad Slots Under Per-User View Caps
Randomly assign eligible ads to page positions for one user, respecting per-user display caps, avoiding repeats when possible, and returning the updated view counts.
Arrays & Hashingrandomizationhash-mapshuffleresource-allocation - Greedy & IntervalsHardModel answerPayroll From an Event Log With Surge Windows
Turn a day's delivery events into total driver pay, then add doubled-rate surge windows by splitting intervals at boundaries, and decide how to handle messy or inconsistent logs.
Greedy & Intervalsintervalsevent-processinghashingsorting - Data Structure DesignMediumAuto-gradedPer-Tab Navigation Timeline Replay
Simulate independent per-tab navigation timelines with a cursor, supporting visit, back and forward, and replay a batch of operations to collect their results.
Data Structure Designdesignhash-mapsimulationcursor - Greedy & IntervalsMediumAuto-gradedDaily Flat-Fee Cap on Overlapping Job Charges
Sum per-day min(active cost, flat fee) over huge day ranges using an event sweep, with the result taken modulo 1,000,000,007.
Greedy & Intervalsline-sweepintervalsdifference-arraymodular-arithmetic - Data Structure DesignMediumModel answerWeighted Random Picker with Live Weight Updates
Design a sampler that picks an index in proportion to its weight, supports weight changes, draws several distinct items, and can be seeded and tested statistically.
Data Structure Designweighted-samplingfenwick-treeprefix-sumsbinary-search - Trees & GraphsMediumModel answerThread-Pooled Link Crawler with Depth Limit and Dedup
Implement a thread-safe crawler that explores links from a seed page to a given depth, never fetches a URL twice, and caps the number of simultaneous fetches.
Trees & Graphsconcurrencybfsthread-poolgraph-traversal - Heaps, Sorting & SearchMediumAuto-gradedPick the Element at a Given Rank From the Top
Find the k-th largest value in an unsorted integer list, counting duplicates separately, without necessarily sorting the whole list.
Heaps, Sorting & Searchheapquickselectselectionarrays - Data Structure DesignHardAuto-gradedTrack Covered Spans Under Add, Erase and Check Commands
Maintain a set of half-open real intervals under add, remove and fully-covered queries, merging touching spans and splitting spans on removal.
Data Structure Designintervalsbinary-searchsimulationsorted-list - Trees & GraphsMediumAuto-gradedCombine Config Trees and Parse a Canonical Encoding
Merge two keyed n-ary trees by summing values, encode them canonically, and strictly parse an encoded string with validation.
Trees & Graphstreerecursionparsingserialization - Arrays & HashingEasyAuto-gradedTally Tokens and Report the Three Most Common
Count occurrences of each string in a list with a hash map, then rank by count with an alphabetical tie-break to extract the top three entries.
Arrays & Hashinghash-mapcountingsortingtie-breaking - Trees & GraphsMediumModel answerRound-Trip Text Encoding for Ordered Trees with Any Number of Children
Define a text format for ordered trees with arbitrary branching, then write an encoder and decoder that rebuild the exact same values, structure and child order in linear time.
Trees & Graphstreeserializationn-ary-treeiterative-dfs - Math & Bit ManipulationMediumAuto-gradedGambler's Ruin: Success Probability and Duration Score
Compute the chance a random walk hits a target before zero using a closed form, handling the fair case and overflow, and return a fixed duration formula.
Math & Bit Manipulationprobabilitymarkov-chainclosed-formnumerical-stability - Dynamic ProgrammingMediumAuto-gradedBest Haul from a Row of Stalls Without Adjacent Picks
Pick values from a row so that no two chosen positions are neighbors, maximizing the total, which tests recognizing and implementing a simple one-dimensional dynamic programming recurrence.
Dynamic Programmingdynamic-programmingarraysnon-adjacent-selection - Data Structure DesignHardModel answerBuild an Exact Usage Ledger for Chunked LLM Responses
Design a billing ledger that merges streamed token deltas and one-shot totals, validates events strictly, and keeps all money as integer nano-USD to avoid floating-point drift.
Data Structure Designdesign-dshash-mapvalidationstate-machine - Trees & GraphsMediumAuto-gradedSmallest Job Schedule Under Dependency Rules
Produce the lexicographically smallest topological ordering of a dependency graph, or an empty list if the dependencies contain a cycle.
Trees & Graphstopological-sortgraphheapcycle-detection - Data Structure DesignMediumModel answerFinish a REST Resource: Update and Delete Routes in FastAPI
Extend a small FastAPI service with replace and remove routes that follow existing conventions, handle idempotency and errors correctly, and ship with a full test suite.
Data Structure Designfastapirest-apipydantichttp-status-codes - Arrays & HashingMediumAuto-gradedUsers Needed Per Group for a Two-Proportion Test
Compute the smallest equal group size for a two-sided two-proportion z-test, given a baseline rate, relative uplift, significance level and target power.
Arrays & Hashingstatisticssample-sizepower-analysisab-testing - Trees & GraphsHardModel answerRewrite a Relational Plan: Sink Filters and Trim Columns
Transform a tree of Scan, Filter, Project and Join operators by moving filters toward the leaves and removing unused columns, while keeping query results unchanged.
Trees & Graphstree-rewritingquery-optimizationpredicate-pushdownprojection-pruning - Data Structure DesignMediumModel answerBuild a Dependency-Aware Cell Calculator with Cycle Checks
Design an in-memory grid of numeric and formula cells in Python, reject circular dependencies, allow shared references, and compare lazy evaluation against eager recomputation with caching.
Data Structure Designdesigngraphcycle-detectionmemoization - StringsMediumAuto-gradedLongest Repeated-Letter Block With a Limited Rewrite Budget
Find the longest block of identical letters obtainable by rewriting at most k characters, testing sliding-window reasoning on majority counts for strings up to 100,000 characters.
Stringssliding-windowstringstwo-pointershashing - Arrays & HashingMediumAuto-gradedWindow Sums Within [k, 2k] for Power-of-Two Lengths
Enumerate every subarray whose length is a power of two and whose sum falls in [k, 2k], using prefix sums to get an O(n log n) solution with ordered output.
Arrays & Hashingprefix-sumsliding-windowsubarrayenumeration - Arrays & HashingMediumAuto-gradedDeterministic Mini-Batch Gradient Descent for a Line Fit
Fit a slope and intercept to 2D points by running deterministic mini-batch gradient descent on mean squared error, with exact batching, update order and edge-case rules.
Arrays & Hashinggradient-descentlinear-regressionmini-batchoptimization