practice a little every day — you've got this ♡
Coding Interview Problems
Practice 6017 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.
- 6017
- Problems
- 2229
- Auto-graded
- 15
- Topics
- 275
- Added today
Showing 841–870 of 2782 results
- Math & Bit ManipulationEasyAuto-gradedPossible Subspace Intersection Dimensions
Computes all valid integer dimensions for the intersection of two vector subspaces given ambient and subspace dimensions.
Math & Bit Manipulationmathlinear-algebra - Arrays & HashingMediumAuto-gradedClosest Bakery Stall for Every Shopper on a Street
For 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.
Arrays & Hashingarraystwo-pointersprefix-suffixnearest-neighbor - Math & Bit ManipulationMediumAuto-gradedFirewall Rule Resolver with Longest-Prefix Priority
Resolve an IPv4 address against CIDR allow/deny rules using longest-prefix precedence, later-rule tie-breaking, and a default of deny, via bitmask matching.
Math & Bit Manipulationbit-manipulationcidripv4simulation - Dynamic ProgrammingMediumModel answer0/1 to Bounded Knapsack Optimization and Traceback
Solve the 0/1 knapsack problem with optimal item selection, optimize its space complexity, and extend the solution to bounded knapsacks efficiently.
Dynamic Programmingdynamic-programmingarrayssliding-windowknapsack - Dynamic ProgrammingHardAuto-gradedVisit Every Node Exactly Once: Path Existence in a Small Graph
Decide whether an undirected graph of at most 20 vertices has a simple path through every vertex, which is best solved with a bitmask DP over visited subsets.
Dynamic Programmingbitmask-dpgraphhamiltonian-pathsubsets - Math & Bit ManipulationMediumAuto-gradedEnumerate Every Factor of a Large Integer in Sorted Order
Produce all positive factors of an integer up to 10^12 in increasing order, handling perfect squares and large primes, and consider approaches faster than a square-root scan.
Math & Bit Manipulationnumber-theorydivisorsfactorizationsquare-root - Heaps, Sorting & SearchMediumAuto-gradedLowest-Sum Pairs Across Two Sorted Lists
Select the k cheapest cross-array pairs from two sorted lists using a heap-based k-way merge, with a deterministic ordering for ties.
Heaps, Sorting & Searchheapk-way mergesorted arrayspriority queue - Trees & GraphsHardModel answerEvaluate Chained Sum Definitions with Error Detection
Compute the integer value of every variable defined as a sum of literals and other variables, raising distinct errors for duplicate, undefined, or circular definitions.
Trees & Graphstopological-sortgraphkahn-algorithmcycle-detection - Math & Bit ManipulationMediumModel answerSpot Hidden Differences Between Two Array Routines
Decide whether two array-processing routines behave identically under 32-bit integer rules, find a smallest counterexample if not, and design tests that expose subtle divergences.
Math & Bit Manipulationprogram-equivalenceinteger-overflowproperty-based-testingdifferential-testing - Trees & GraphsMediumAuto-gradedTree Span and Grid Escape: Two Graph Queries in One Call
Compute a tree's longest path in edges and the shortest 4-directional route through a grid with obstacles, returning both results together.
Trees & Graphsbfstree-diametershortest-pathgrid - Data Structure DesignMediumAuto-gradedChat Activity Tracker with a Rolling 15-Minute Window
Simulate a chat activity tracker with a closed rolling window, touch/close liveness rules, and out-of-order events, using bounded-memory eviction.
Data Structure Designdesignhash-mapheapsliding-window - Stacks & QueuesEasyAuto-gradedCollapse Repeated Letters: Pair Cancel or Full Run Wipe
Simulate cascading deletions of equal neighbouring letters with a stack, either cancelling pairs or erasing whole leftmost runs, and return what is left.
Stacks & Queuesstackstringsimulationrun-length - Arrays & HashingMediumAuto-gradedCount Index Pairs With a Fixed Value Gap
Count 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.
Arrays & Hashinghash-mapcountingfrequencypairs - Heaps, Sorting & SearchMediumAuto-gradedBudget Growth Through Threshold-Locked Ventures
Greedy plus min-sorted unlocking and a max-heap: pick up to k ventures, each requiring a minimum budget, to maximize the final budget.
Heaps, Sorting & Searchgreedyheapsortingpriority-queue - Trees & GraphsMediumAuto-gradedCount Islands of Mutual Acquaintances in a Matrix
Count connected components in an undirected graph given as a symmetric adjacency matrix, without modifying the input, using graph traversal or union-find.
Trees & Graphsgraphconnected-componentsdfsunion-find - Data Structure DesignMediumModel answerRandom Equipment Lending Pool with Constant-Time Operations
Build an in-memory pool that lends out a uniformly random free item to a borrower, accepts returns, and allows retirement of idle items, with every operation in O(1) average time.
Data Structure Designhash-maprandomizedswap-and-popinsert-delete-getrandom - StringsMediumAuto-gradedLongest Stretch of Non-Repeating Characters
Find the length of the longest contiguous run in a string where every character is distinct, using a linear-time sliding window with index tracking.
Stringssliding-windowhash-maptwo-pointersstrings - Heaps, Sorting & SearchMediumModel answerRandom Index Selection by Given Weights
Design an index sampler where each element's probability of being chosen is proportional to its assigned weight.
Heaps, Sorting & Searchprefix-sumbinary-searchrandomizationdata-structure-design - Math & Bit ManipulationEasyModel answerTwo Islanders, One Accusation: Which Role Pairs Work?
One islander accuses the other of always lying. Test all four role pairings and decide which ones are logically possible.
Math & Bit Manipulationlogicpuzzlecase-analysisknights-and-knaves - Heaps, Sorting & SearchMediumAuto-gradedLocate the Span of a Value in a Sorted List
Use binary search to find the first and last positions of a value in a sorted list with duplicates, in logarithmic time, returning [-1, -1] if it is absent.
Heaps, Sorting & Searchbinary-searcharraysbisectsorted-array - Arrays & HashingMediumAuto-gradedCollapse Rapid Cart Adds into Daily Pacific Action Counts
Filter 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.
Arrays & Hashinghashinggroupingdatetimetimezones - Arrays & HashingMediumModel answerBest Single Trade Within a Limited Holding Period
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.
Arrays & Hashingsliding-windowblock-decompositionmonotonic-dequestock-trading - Trees & GraphsMediumModel answerRepairing a Search Tree After One Pair of Keys Trades Places
Two keys in a binary search tree were exchanged by mistake. Restore ordering by swapping values back, keeping the shape intact, in linear time and constant extra space.
Trees & Graphsbinary-search-treemorris-traversalin-ordertree-recovery - Data Structure DesignMediumAuto-gradedDesign a Dispatch Queue for Autonomous Taxi Requests
Simulate an event-driven dispatching system that maintains pending requests ordered by pickup time and processes state updates efficiently using heaps and hash maps.
Data Structure Designheaphash-tabledesignsorting - Greedy & IntervalsMediumAuto-gradedCombine Overlapping Ranges and Count Unique Land Shapes
Merge overlapping or touching closed ranges, and count land regions in a binary grid that differ in shape when only shifting is allowed.
Greedy & Intervalsintervalssortingdfsgrid - Arrays & HashingEasyAuto-gradedFind the Maximum Value in a Large Numerical Stream
Find the maximum integer in a sequence while accounting for empty inputs and signed values.
Arrays & Hashingarraysstreamingbasics - Math & Bit ManipulationEasyAuto-gradedIs This Dice Wager Worth Playing? Expected Value Check
Count outcomes of a two-dice contest where ties favor the house, compute the expected profit per round, and decide whether a risk-neutral player should take the bet.
Math & Bit Manipulationprobabilityexpected-valuemathcounting - Arrays & HashingEasyAuto-gradedIdentify Redundant Files by Content Matching
Cluster files that share identical byte contents by filtering first on file size metadata and then hashing content.
Arrays & Hashingarrayshash mapstrings - Linked ListsMediumAuto-gradedDuplicate Linked List with Arbitrary Pointers
Demonstrate deep copying of a sequential structural chain featuring auxiliary target links via node-level or serialized array transformations.
Linked Listslinked-listsarraysdeep-copy - Data Structure DesignHardAuto-gradedLeftmost-Fit Block Reservation with Owner Release
Simulate a storage pool that reserves the leftmost run of contiguous free cells per request and releases everything an owner holds, using efficient free-run tracking.
Data Structure Designsegment-treesimulationinterval-merginghash-map