CODING TESTS
Python Coding Tests
Function problems graded by hidden tests
Complete a function, and it is graded on the visible examples and on hidden tests. Practice reading the constraints and thinking of edge cases yourself, such as the smallest and the largest values.
66 problems
Start practicing in your browser
Chapter 1: Reading the problem Size it up from the constraints and imagine the hidden tests
1.1 Digits The remainder and quotient after dividing by 10
- Adding up the digits Write code · Basic
- Counting a digit Write code · Medium
1.2 Sizing up Using the constraints to judge whether a loop ends in time
- The day you exceed the goal Write code · Medium
Chapter 2: Implementation Math problems where every condition goes into code
2.1 Primes Narrowing the range of divisors to try
- Prime check Write code · Basic
- Counting primes Write code · Medium
- The k-th prime Write code · Challenge
2.2 Divisors and multiples Paired divisors and counting formulas
- Finding divisors Write code · Basic
- GCD and LCM Write code · Medium
- Sum of multiples of 3 or 5 Write code · Basic
2.3 Turning conditions into code Problems that spell out their conditions
- Rice bags Write code · Challenge
Chapter 3: Lists and strings Ranking, shifting, and handling characters
3.1 Finding ranks Keeping track of first and second place together
- Second-highest score Write code · Medium
- First and second place Write code · Medium
3.2 Shifting and ranges Rotation cut down with remainders, and prefix sums
- Rotating a list Write code · Medium
- Range sums Write code · Medium
3.3 Working with strings Splitting, reversing, and compressing strings
- Collecting hashtags Write code · Basic
- Reversing each word Write code · Basic
- Compressed notation Write code · Medium
Chapter 4: Hashing Dictionaries and sets
4.1 Remembering what you have seen Instant lookup with a set
- First repeated ID Write code · Basic
- Common interest tags Write code · Basic
- Comments you can see Write code · Basic
4.2 Pairs as keys Sets of tuples
- Mutual follows Write code · Medium
- Like and unlike Write code · Medium
4.3 Counting occurrences Counting with the dictionary get method
- Most frequent number Write code · Challenge
- Hashtags used only once Write code · Basic
Chapter 5: Stacks and queues Two structures that take things out in different orders
5.1 Stacks Last in, first out
- Matching brackets Write code · Medium
- Undo Write code · Medium
- Undo and redo Write code · Medium
- Matching format tags Write code · Medium
5.2 Queues First in, first out
- Leaving the circle Write code · Challenge
- Question queue Write code · Medium
- Stopping comment spam Write code · Challenge
Chapter 6: Sorting and greedy Sort keys, neighbors after sorting, and picking the best option now
6.1 Putting things in order Sort keys and the order of equal values
- Ranking by likes Write code · Medium
- Middle value Write code · Basic
- Popular hashtags Write code · Medium
6.2 Neighbors after sorting Comparing neighbors once the list is sorted
- Shortest gap Write code · Challenge
- Longest attendance streak Write code · Medium
6.3 Greedy Picking the best option right now
- Uploading photos to storage Write code · Basic
- Watching shows without overlap Write code · Challenge
Chapter 7: Brute force Trying every case
7.1 Trying them all Estimating the number of cases from the constraints
- Two posts with a target sum Write code · Basic
- Making three-digit numbers Write code · Medium
- Digits on a clock Write code · Medium
7.2 Permutations and combinations Using itertools to make every way of choosing
- Friend triangles Write code · Medium
- Feed order Write code · Medium
- Splitting into two teams Write code · Challenge
- Similar posts Write code · Medium
Chapter 8: Binary search Throwing away half each time
8.1 Searching a sorted list Finding positions with bisect
- Posts at or above the bar Write code · Basic
- Follower count ranges Write code · Medium
- The page a post is on Write code · Medium
8.2 Writing binary search yourself Boundaries and stopping conditions
- Same score, same rank Write code · Medium
- The nickname back then Write code · Medium
8.3 Guessing the answer and checking it Finding the answer with a yes-or-no check
- Choosing the length of shorts Write code · Medium
- Sending notifications in batches Write code · Challenge
Chapter 9: DFS and BFS Walking grids and relationships
9.1 Following relationships Adjacency lists and connected groups
- Groups linked by follows Write code · Medium
- A post spreading through shares Write code · Challenge
9.2 Walking a grid Groups in a grid
- Counting check-in areas Write code · Medium
- Largest color region Write code · Medium
9.3 Nearest first Shortest distance with BFS
- Walking to a friend in the plaza Write code · Medium
- Passing news by DM Write code · Medium
- A wave through the audience Write code · Challenge
Chapter 10: Dynamic programming Reusing earlier answers
10.1 Recursion that repeats work From recursion to a one-dimensional table
- Quiz points Write code · Basic
- Notification days Write code · Medium
10.2 Filling a one-dimensional table Building the next answer from earlier ones
- Ad-free passes Write code · Medium
- Splitting a hashtag into words Write code · Challenge
10.3 Two-dimensional grid tables Counting paths in a grid
- Paths around walls Write code · Medium
- Path with the highest score Write code · Medium
- Counting the best paths Write code · Challenge