DSA and coding interview practice
Original coding interview problems as two-minute exercises. Commit to an answer first, then check it and read the full explanation with runnable Python.
Prefer to just read? Every question has Show answer. Progress is saved on this device only, separately from the iOS, Android and Backend courses.
- PredictPick what the code returns, or tap the line with the bug.
- CheckSee whether you were right, and why every other option is wrong.
- Learn itRead the 30-second answer, then the solution, its cost and the follow-ups.
– interview-ready · 200 questions
– of 200 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Daily 5
The same five questions for everyone today, with a grid to share. Needs JavaScript. Start with the first question.
Readiness by topic
Your progress is saved in this browser only. With JavaScript on, this shows each topic's readiness and lets you export your progress to a file or import it on another device.
Share your progress
Topics
Arrays, strings and hash maps
Hash sets and maps for seen-before checks, complements, counting keys and prefix sums; in-place array tricks; what lists and dicts really cost.
14 questions
Two pointers
Pointers from both ends of sorted data, read and write pointers for in-place edits, and merging sorted sequences, with the reasoning that makes them correct.
12 questions
Sliding window
Fixed and variable windows over arrays and strings, the amortised argument that makes them linear, and when a window is the wrong tool.
12 questions
Trees
Binary tree recursion, traversal orders, level-by-level walks, binary search tree rules and the questions built on them, all with one small Node class.
16 questions
Graphs
Grids and networks as graphs: BFS and DFS, multi-source BFS, topological order, union-find, Dijkstra and minimum spanning trees, with the costs you need to state.
22 questions
Complexity analysis
Big O in plain words, reading the cost of loops and recursion, amortised and space costs, what Python's built-in operations really cost, and which input sizes fit which algorithms.
14 questions
Stacks and queues
Stacks for matching and undo, queues for order of arrival, monotonic stacks for 'next bigger' questions, and how to build one from the other.
12 questions
Searching sorted data
Binary search on sorted lists, on rotated lists and grids, and on the answer itself, with the loop invariants that prevent off-by-one bugs.
12 questions
Linked lists
Chains of links: turning them around, fast and slow pointers, the placeholder head, and when a chain beats a Python list.
10 questions
Heaps and priority queues
Min-heaps by hand and with heapq: the k largest, merging sorted feeds, running medians and greedy choices that always take the smallest or biggest next.
10 questions
Backtracking
Choose, explore, undo: listing selections and orderings, searching grids and boards, and pruning the search so exponential work stays small in practice.
12 questions
Dynamic programming
Turning repeated recursion into tables: state, transition, base case and fill order, from one-row counts to two-string tables, with the memory tricks interviewers ask about.
18 questions
Greedy choices and intervals
Sorting intervals by start or end, sweeping through events, and greedy rules you can prove with an exchange argument.
12 questions
Strings and tries
Prefix trees for lookups and suggestions, expanding around centres, linear-time pattern search, and what Python strings cost.
10 questions
Bits and maths
XOR, masks and shifts, counting 1 bits, and the modular arithmetic that keeps big counts manageable.
6 questions
Interview craft
How to run a coding interview from the first question to the last test: clarifying, choosing a pattern, talking while you code, dry runs and testing.
8 questions
All questions
Arrays, strings and hash maps
- Spot the first repeated badge at the doorPredict
- Two gift prices that hit the budget exactlyFill the blank
- Group tile racks that hold the same lettersPredict
- Count sales stretches that add up to a targetPredict
- Longest run of consecutive ticket numbersPick the fix
- Find the value that fills more than half the listPredict
- Each shelf's product of all the other shelvesSpot the bug
- Shift a playlist k places to the right, in placeOrder the steps
- First order code that appears only oncePredict
- Find the balance point of a seesawFill the blank
- How a hash map keeps lookups fast on averagePick the fix
- Why appending to a list is amortized O(1)Predict
- What makes a good dictionary keyPredict
- Count or sort: choosing a frequency toolPredict
Two pointers
- Do two sorted prices add up to a target?Predict
- Push the empty parking slots to the endSpot the bug
- Does a banner read the same both ways?Predict
- Merge two sorted shelves into oneFill the blank
- Remove repeated readings from a sorted log in placePredict
- Count weight triples that stay under a limitPredict
- Squared deviations in sorted orderPick the fix
- Is a short route hidden inside a long one?Predict
- Sort a tray of three token colours in one passSpot the bug
- When do two pointers work, and why?Pick the fix
- Same-direction vs opposite-end pointersPredict
- In place or a new list: what the interviewer meansPredict
Sliding window
- Longest streak of days within a budgetPredict
- Longest stretch of a log with no letter seen twiceSpot the bug
- Best total over k consecutive daysFill the blank
- Shortest run of orders that reaches a goalPredict
- Where does a rearranged pattern appear in a text?Predict
- Longest single-colour run after repainting k tilesPick the fix
- Best single buy-then-sell on a price historyPredict
- Longest stretch with at most two kindsPredict
- Busiest hour in each k-hour spanFill the blank
- Fixed-size vs variable-size windowsPick the fix
- Why a window with a nested loop is still O(n)Predict
- When a sliding window does not workPredict
Trees
- How trees are written on these pagesPredict
- How deep is the deepest branch?Pick the fix
- Is this a valid binary search tree?Pick the fix
- List a tree's values row by rowFill the blank
- Are two trees identical?Predict
- Does a tree mirror itself?Pick the fix
- Swap every node's left and right childrenPredict
- Longest path between any two nodesPick the fix
- Is every node's left and right height within one?Predict
- What you see from the right of a treePick the fix
- The k-th smallest value in a search treeOrder the steps
- Closest shared ancestor in a search treePredict
- Does a root-to-leaf route add up to a target?Pick the fix
- Pre-order, in-order, post-order and level orderPredict
- Why search trees need to stay balancedPredict
- Recursion depth and when to walk a tree iterativelyPredict
Graphs
- Count the separate patches of land on a mapPredict
- Can every task finish, given its prerequisites?Pick the fix
- Minutes until every item on a shelf spoilsFill the blank
- How many separate groups does a network have?Predict
- Fewest hops between two stationsPick the fix
- Fastest delivery time to every depotPredict
- The earliest valid task orderPredict
- Seat guests at two tables with no feud at eitherPick the fix
- Which cable closes a loop?Predict
- Area of the biggest patch of landPredict
- Repaint the connected region of a picturePick the fix
- Fewest one-letter changes between two code wordsPredict
- Does a dependency graph contain a loop?Pick the fix
- Cheapest way to cable every office togetherOrder the steps
- Cells whose rain reaches both coastsPick the fix
- Fill in the water that does not touch the edgePredict
- Adjacency list, adjacency matrix or edge list?Predict
- BFS or DFS: which one to usePick the fix
- Mark visited when you push or when you pop?Predict
- Why Dijkstra fails with negative weightsPick the fix
- Union-find: how it works and when to reach for itPredict
- Grids are graphs: neighbours, bounds and costsPredict
Complexity analysis
- Big O in plain wordsPredict
- Reading the cost of loopsPredict
- Where O(log n) comes fromPredict
- Amortised cost: cheap on average, sometimes slowPredict
- Space complexity and the call stackPredict
- What common Python operations costPredict
- Which complexity fits which input sizePredict
- Best, average and worst casePredict
- Working out the cost of recursionPredict
- How fast can sorting be?Predict
- The cost of building stringsPredict
- The cost table for common data structuresPick the fix
- Answer many range-total questions quicklyFill the blank
- Raise a number to a huge power, modulo mPredict
Stacks and queues
- Do the brackets in a line balance?Predict
- How many days until a warmer day?Pick the fix
- A stack that also reports its minimumPredict
- Evaluate an expression written in postfix orderPredict
- Apply the backspaces in typed textPredict
- Build a queue out of two stacksPredict
- Tidy a file path with . and .. partsPredict
- Largest poster that fits under a skylinePredict
- How many requests arrived in the recent window?Fill the blank
- Stack or queue: LIFO and FIFOPredict
- The monotonic stack patternPredict
- Recursion is a stack: converting to an explicit onePredict
Searching sorted data
- Where would a new price go in a sorted list?Predict
- Slowest reading pace that still finishes on timePredict
- Smallest value in a rotated sorted listPick the fix
- Find a value in a rotated sorted listPredict
- First and last position of a value in a sorted listFill the blank
- Whole-number square root without math.sqrtPredict
- Smallest truck that delivers every parcel in d daysPredict
- Highest point of a climb-then-descent routePick the fix
- Find a value in a grid sorted row after rowPredict
- Binary search without off-by-one bugsPredict
- Binary search on the answerPick the fix
- Using bisect and sorted lists in practicePredict
Linked lists
- How linked-list questions give you the chainPredict
- Turn a chain of links aroundOrder the steps
- Does the chain loop back on itself?Pick the fix
- Drop the k-th link from the endPredict
- Weave two sorted chains into oneFill the blank
- Fold a chain: first, last, second, second-lastPredict
- Sum two numbers stored digit by digitPredict
- Does a chain read the same backwards?Pick the fix
- The placeholder head trickSpot the bug
- When a chain beats a Python listPick the fix
Heaps and priority queues
- Push values into a min-heap by handPredict
- The k-th biggest readingFill the blank
- Merge many sorted feeds into onePredict
- The k depots nearest the warehousePredict
- Fewest time slots when each job type needs a cooldownPredict
- Median after each new readingPredict
- Smash the two heaviest rocks until one is leftPredict
- Cheapest way to join ropes into onePredict
- How a binary heap worksPredict
- Heap, sort or quickselect?Pick the fix
Backtracking
- Count the picks that hit an exact totalPredict
- Every order of a playlistPredict
- Every selection from a set of toppingsPredict
- Every team of k from n playersFill the blank
- Every balanced string of n bracket pairsPredict
- Trace a word through a letter gridPick the fix
- Cut a word into pieces that each read the same backwardsPredict
- Count the ways to place queens that cannot attackPredict
- Every distinct order when songs repeatPredict
- The backtracking template: choose, explore, undoOrder the steps
- Pruning: making exponential searches fast enoughPick the fix
- How big is the search space?Predict
Dynamic programming
- Ways to cross n stepping stones, one or two at a timePredict
- Fewest coins to make an amountPredict
- Fewest edits to turn one word into anotherPredict
- Best haul without opening two neighbouring lockersPredict
- Best haul when the lockers form a ringPick the fix
- Ways to read a digit string as letters (1 = A … 26 = Z)Predict
- Can a string be split into dictionary words?Predict
- Longest rising sequence of picks from a listPredict
- Longest shared subsequence of two stringsPredict
- Routes across a grid with blocked cellsPredict
- Cheapest route from top-left to bottom-rightPredict
- Split items into two piles of equal weightPredict
- Number of ways to pay an amount with unlimited coinsPredict
- Largest product of a contiguous runPredict
- Dynamic programming in four stepsOrder the steps
- Top-down caching or bottom-up tables?Predict
- Saving memory with rolling rowsPredict
- How to tell a problem needs DPPick the fix
Greedy choices and intervals
- Combine overlapping bookings into blocksPredict
- Fewest bookings to cancel so none clashPick the fix
- How many rooms do the bookings need at once?Predict
- Add a booking to a sorted list of separate blocksPredict
- Can you hop to the last tile?Predict
- Fewest hops to the last tilePredict
- Where to start a delivery loop so the van never runs dryPredict
- Cut a string into the most chunks so no letter crosses a cutPredict
- Largest total of a contiguous runPredict
- When does a greedy choice work?Pick the fix
- Sort intervals by start or by end?Pick the fix
- Sweep-line thinkingPredict
Strings and tries
- How many words start with a given prefix?Predict
- Longest stretch that reads the same backwardsPredict
- First place a pattern appears in a textPredict
- Top three suggestions as you typePredict
- Look up words where '.' stands for any letterPredict
- Count the stretches that read the same backwardsPredict
- Longest start shared by every wordPredict
- What Python string operations costPredict
- Trie or hash set?Pick the fix
- Rolling hashes for pattern searchPredict
Bits and maths
- The one value without a partnerPredict
- Count the 1 bits in a numberPredict
- 1-bit counts for every number from 0 to nPredict
- Which ticket from 0 to n is absent?Predict
- Bit tricks worth knowingPredict
- Working modulo 10⁹ + 7Predict
Interview craft
- Spotting the pattern from the questionPick the fix
- The first five minutes of a coding interviewOrder the steps
- Brute force first, then improvePredict
- Count position pairs whose values differ by exactly kPredict
- Talking while you codePick the fix
- Dry run: the first day an account is overdrawnPredict
- Testing your own code in an interviewPredict
- What to do when you are stuckOrder the steps
Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license