Practice
Practice problems
24 problems, each graded against hidden test cases — not just the examples you can see. Write your solution, run it against the samples, then submit it and find out whether it really works.
12 easy9 medium3 hard8 debugging labsSolve in Python or JavaScript · graded in your browser
What these are for
These are the problems that come up in technical interviews and, more usefully, the ones that teach you to reason about what your code costs. Each states its constraints and a complexity target up front, so you know what you are aiming for rather than guessing whether a working answer is a good one.
The debugging labs work the other way round: you are handed a program that runs but produces the wrong answer, plus the bug report. Most of a working developer's day looks more like that than like writing from a blank editor, and the same hidden tests decide when you have actually fixed it.
They are a big step up from the beginner exercises. If a problem statement reads as a wall of words, that is a sign to do the exercises and the lessons first, then come back.
The problems
24 problems
Data structures and algorithms (16)
- Balanced ParenthesesEasyThe input line has between 0 and 10,000 characters.Python · target O(n)StackStringData Structure
- Best Contiguous RunEasyThe input line has at least 1 and at most 100,000 integers.Python · target O(n)ArrayDynamic ProgrammingTime Complexity
- Binary SearchEasyThe array has at least 1 integer and at most 100,000 integers.Python · target O(log n)Binary SearchArrayTime Complexity
- Binary Tree Level Order SumEasyThe tree is given as an array of 1 to 1,000 entries, position 0 being the root.Python · target O(n)QueueArrayRecursion
- Cycle in a Sequence ChainMediumThe chain has between 1 and 100,000 nodes, indexed 0 to n - 1.Python · target O(n)Linked ListAlgorithmSpace Complexity
- Fewest Coins for AmountHardThere are between 1 and 50 coin denominations, each a distinct positive integer between 1 and 10,000.Python · target O(amount * k)Dynamic ProgrammingRecursionTime Complexity
- Group Word ClustersEasyThe input has at least 1 and at most 500 words.Python · target O(n * k log k)Hash TableSortingString
- Longest Stretch Without a RepeatMediumThe input line contains only lowercase English letters (a-z) and may be empty.Python · target O(n)StringHash TableTwo Pointers
- Merge Overlapping BookingsMediumThe input has at least 1 and at most 2,000 intervals.Python · target O(n log n)SortingArrayTime Complexity
- Nth Fibonacci Number (Memoized)Medium0 <= n <= 35Python · target O(n)RecursionDynamic ProgrammingTime Complexity
- Reverse Words in a StringEasyThe input line has length at most 10,000 characters.Python · target O(n)StringArrayEdge Case
- Shortest Hop CountHardThe graph has between 1 and 100,000 nodes, numbered 0 to n - 1, and between 0 and 200,000 edges.Python · target O(n + m)QueueData StructureTime Complexity
- Two Number SumEasyThe array has at least 2 integers.Python · target O(n)ArrayHash TableTime Complexity
- Valid PalindromeEasyThe input line has between 0 and 1,000 characters.Python · target O(n)StringTwo PointersPalindrome
- Warmer Day CountdownMediumThe input line has at least 1 and at most 100,000 integers.Python · target O(n)StackArrayData Structure
- Widest Water TankMediumThe input line has at least 2 and at most 100,000 non-negative integers.Python · target O(n)ArrayTwo PointersTime Complexity
Debugging labs (8)
- Class Average To Two DecimalsEasyThe first line is n, the number of scores, with 1 <= n <= 10,000.Python · target O(n)ArrayEdge CaseAlgorithm
- Count The Target TicketEasyThe first line holds between 1 and 20,000 ticket numbers separated by single spaces.Python · JavaScript · target O(n)ArrayStringEdge Case
- Largest Gap Between ReadingsEasyThe first line is n, the number of readings, with 2 <= n <= 50,000.Python · target O(n)ArrayEdge CaseTime Complexity
- Long Words Per LineHardThe first line holds two integers separated by a single space: t, the number of word lines that follow (1 <= t <= 50), and k, the minimum length (1 <= k <= 20).Python · target O(w)StringArrayData Structure
- Longest Win StreakMediumThe first line is t, the number of teams, with 1 <= t <= 200.Python · target O(c)StringAlgorithmEdge Case
- Lowest Reading Of The DayEasyThe input is one line of between 1 and 50,000 integers separated by single spaces.Python · JavaScript · target O(n)ArrayEdge Case
- Strictly Increasing CheckMediumThe first line is t, the number of sequences, with 1 <= t <= 200.Python · target O(v)ArrayEdge CaseAlgorithm
- Top Three ScoresMediumThe first line is n, the number of scores, with 3 <= n <= 20,000.Python · JavaScript · target O(n log n)SortingArrayAlgorithm
Practise one language, start to finish
Each language with an exercise path also has a practice hub: its exercises, graded problems, lessons, cheat sheet and playground on one page.
Questions about the practice problems
- What does 'hidden test cases' actually mean here?
- Each problem is graded against tests you can see (the samples) and tests you cannot (the hidden ones), so a solution that only fits the samples fails. Because the site has no server, 'hidden' means not shown on the page and fetched only when you press Submit — a determined person can find them in the browser's network tab. They exist to make the feedback honest, not to stop cheating.
- Which language can I solve the problems in?
- Whichever the problem lists, and most are Python-only today. A handful of the debugging-lab problems also accept JavaScript, and each problem page shows a language picker above the editor when more than one is offered. The problem statements are language-independent, so you can always solve one in any language on your own computer even when in-page grading does not yet run it.
- Are these the exact questions companies ask in interviews?
- No, and no site can honestly claim that. These are classic problem shapes — pairs that sum to a target, balanced brackets, binary search — chosen because of what they teach about data structures and complexity, which is what interviews test.
The ideas behind the problems
Every term a problem leans on — hash table, two pointers, time complexity — is defined in plain English with a small example in the programming glossary. Some problems accept more than one language: each problem page says which, and the picker sits above the editor. Anything you want to try outside a problem belongs in a playground.