practice a little every day — you've got this ♡
Coding Interview Problems
Practice 6011 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.
- 6011
- Problems
- 2228
- Auto-graded
- 15
- Topics
- 276
- Added today
Showing 721–750 of 2781 results
- Trees & GraphsMediumAuto-gradedTally Separate Clusters of Occupied Cells in a Grid
Count groups of orthogonally touching '1' cells in a character grid, a connected-components task solved with an iterative flood fill or union-find.
Trees & Graphsgraphbfsgridconnected-components - Data Structure DesignMediumAuto-gradedHourly Courier Pay Ledger with Settlement Watermark
Simulate a payroll ledger that records work intervals, tracks accrued cost, and settles wages up to a cutoff time without double-paying.
Data Structure Designdesignsimulationintervalsidempotency - Arrays & HashingEasyAuto-gradedPair Sum Existence Check in an Integer List
Decide 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.
Arrays & Hashinghash-settwo-sumarrayscomplement - Data Structure DesignMediumAuto-gradedReplay Commands on a Fixed-Bucket Key-Value Store
Simulate a hand-built key-value store with a fixed bucket count by replaying a command log, handling collisions and overwrites correctly without a built-in dictionary.
Data Structure Designhash-tableseparate-chainingsimulationdesign - Data Structure DesignMediumModel answerC++ Polymorphism: Overridable Methods vs Mandatory Interface Methods
Explain how C++ virtual and pure virtual functions differ, how vtable dispatch works, when a class is abstract, and how virtual destructors affect safe cleanup.
Data Structure Designcpppolymorphismvtableabstract-classes - Data Structure DesignMediumModel answerDesign a Resilient In-Memory Task Queue with Worker Failure Handling
Build a thread-safe, in-process job queue that handles worker crashes, lease timeouts, late reports, and retry bounds using deterministic testing mechanics.
Data Structure Designdesign-dsstacks-queuesconcurrencythreads - Dynamic ProgrammingMediumAuto-gradedLongest Eastward Chain of Cities from Raw CSV Text
Parse CSV text with quoted fields, then find the longest chain of cities with increasing longitude and non-decreasing latitude, breaking ties by the smallest list of names.
Dynamic Programmingcsv-parsinglongest-increasing-subsequencedag-dplexicographic-tiebreak - Data Structure DesignMediumAuto-gradedTicket Ranges: Find the Bucket Owning Each Draw
Map integer draws to the index whose cumulative weight range contains them, using prefix sums and binary search, driven through a batch of init/query operations.
Data Structure Designprefix-sumbinary-searchdesignbisect - Dynamic ProgrammingMediumAuto-gradedOptimal Closed Tour Cost Across Directed Locations
Find the minimum cost to complete a full circuit starting and ending at node 0, visiting all other nodes exactly once with asymmetric leg costs.
Dynamic Programmingdynamic-programmingbit manipulationgraph - Data Structure DesignMediumAuto-gradedClosest Pair Gaps Between Words in a Fixed List
Answer many closest-index-distance queries over a fixed word list by building a position index, precomputing same-word gaps, and binary searching the smaller list.
Data Structure Designinverted-indexbinary-searchpreprocessinghash-map - Stacks & QueuesMediumModel answerSimulated Stock Trading Signals and Two-Char String Reduction
Solve two streaming state problems: daily stock trading based on sign patterns in O(N) time and two-character substring elimination using an in-place stack.
Stacks & Queuesstacks-queuesarraysstringsmath-bits - Linked ListsMediumAuto-gradedFlip Every Complete Block of K in a Sequence
Reverse each full consecutive block of k items in a list, leaving a shorter leftover tail unchanged; tests pointer-style reversal logic and boundary handling.
Linked Listslinked-listin-place-reversaltwo-pointerssimulation - Heaps, Sorting & SearchMediumAuto-gradedTop K Highest Scores in Descending Order
Select the k greatest values from an unsorted integer list, duplicates included, returned from largest to smallest, ideally in O(n log k) time using a bounded min-heap.
Heaps, Sorting & Searchheaptop-ksortingarrays - Greedy & IntervalsMediumAuto-gradedFewest Brackets to Add for a Balanced String
Count the fewest parenthesis insertions needed to make a string of brackets balanced, using a single left-to-right pass with a running counter.
Greedy & Intervalsgreedystringsparenthesescounter - Trees & GraphsMediumAuto-gradedFind Minimum Network Distance Between Users
Compute the shortest path distance between two nodes in an unweighted undirected graph using Breadth-First Search.
Trees & Graphsbfsgraphshortest-pathbreadth-first-search - StringsEasyModel answerRound Decimal Strings to a Power-of-Ten Step, No Floats
Round a decimal string to the nearest integer, then to a power-of-ten step such as 100 or 0.1, using only string and digit operations and a clearly stated tie-breaking rule.
Stringsstringsroundingbig-numberscarry - Trees & GraphsMediumAuto-gradedReconstruct Alphabet Order from Sorted Vocabulary
Determine character precedence in an unfamiliar alphabet using a sorted list of terms, returning the lexicographically first valid character sequence or an empty string for invalid inputs.
Trees & Graphstrees-graphsheaps-sortingstrings - Dynamic ProgrammingMediumAuto-gradedStock Trading With a Per-Sale Commission
Compute the best total gain from repeatedly buying and selling a single share of a stock when each sale costs a flat commission, using a two-state dynamic program.
Dynamic Programmingdynamic-programmingstate-machinestocksgreedy - Arrays & HashingMediumAuto-gradedPrefix Value Blocks in a Shuffled Sequence
Decide, 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.
Arrays & Hashingpermutationindex-mappingrunning-min-maxstring-output - Data Structure DesignMediumModel answerNon-Blocking Concurrent Log Writer with Bounded Buffer
Build a thread-safe logger whose callers never wait on slow sink I/O, preserving submission order, bounding memory, and flushing every accepted message on shutdown.
Data Structure Designconcurrencyproducer-consumerbounded-queuebackpressure - Dynamic ProgrammingMediumAuto-gradedRearrangements of 1..m With a Fixed Number of Out-of-Order Pairs
Count arrangements of 1..m with exactly n out-of-order pairs, modulo 10^9+7, using a DP over insertion positions optimized with a sliding-window sum.
Dynamic Programmingdynamic-programmingcombinatoricspermutationssliding-window - StringsEasyAuto-gradedEarliest Non-Repeating Character with Optional Case Folding
Find the position of the earliest character that occurs exactly once in a string, with a flag that switches between case-sensitive and case-insensitive matching.
Stringsstringshash-mapcountingcase-folding - Math & Bit ManipulationEasyAuto-gradedCalculate Expected Return from Two Six-Sided Dice
Computes the expected payoff of a game played with two independent six-sided dice, rounded to two decimal places.
Math & Bit Manipulationmath-bitsprobabilitysimulation - StringsMediumAuto-gradedList Every Well-Formed Bracket Sequence in Dictionary Order
Enumerate all well-formed bracket sequences using n pairs, returned in dictionary order, testing pruned backtracking and reasoning about output ordering.
Stringsbacktrackingrecursioncombinatoricsstrings - Arrays & HashingMediumAuto-gradedQuarter-Turn a Square Grid of Pixels Without Extra Storage
Turn 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.
Arrays & Hashingmatrixin-placesimulationtranspose - Math & Bit ManipulationEasyAuto-gradedYearly Earnings Report for a Rewards Membership Program
Compute yearly revenue, cost, profit and per-member profit for a membership program from fees, monthly spend commission, and fixed and variable costs.
Math & Bit Manipulationmatharithmeticunit-conversionsimulation - Trees & GraphsMediumAuto-gradedFewest Removals to Cap a Rooted Tree's Height
Count the minimum non-root nodes to remove from a parent-array tree, splicing children upward, so the height is at most a limit; tests subtree heights and a path-decomposition argument.
Trees & Graphstreesubtree-heightiterative-bfsgreedy - Data Structure DesignMediumModel answerBuild an In-Memory Ledger with Deposits and Transfers
Implement an in-memory ledger class supporting account creation, deposits and transfers, with clear return codes, invariants, retry safety and concurrency choices.
Data Structure Designhash-mapclass-designidempotencyconcurrency - Dynamic ProgrammingHardAuto-gradedBalanced Parentheses After Digit-Driven Removals
Decide whether removing parentheses to satisfy per-digit quotas can leave a balanced bracket string, using a DP over balance and removal count.
Dynamic Programmingdynamic-programmingstringsparenthesesstate-compression - Trees & GraphsEasyAuto-gradedPrune a Labeled Tree by Forbidden Substring
Recursively copy an n-ary tree while dropping every node whose label contains a given substring, together with its subtree, without mutating the input.
Trees & Graphstreerecursiondfsstrings