Sponsored Reserved space — layout preview until AdSense is connected
Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

56 challenges 25 easy 23 medium 8 hard
Sponsored Reserved space — layout preview until AdSense is connected
Python Basics medium

Fibonacci(n)

Return the nth Fibonacci number efficiently.

recursion dp memoization
+15 pts 15m
Strings & Text medium

Run-length encoding

Compress consecutive identical characters, e.g. 'aaabbc' → 'a3b2c1'.

strings compression
+20 pts 20m
Strings & Text medium

Longest common prefix

Find the longest common prefix among a list of strings.

strings zip
+18 pts 18m
Strings & Text medium

Integer to Roman

Convert a positive integer to its Roman numeral representation.

strings greedy
+22 pts 22m
Strings & Text medium

Zigzag string conversion

Encode a string in zigzag order across numRows rows, then read row by row.

strings math
+22 pts 20m
Lists & Arrays medium

Maximum subarray (Kadane)

Find the contiguous subarray with the largest sum.

dp arrays kadane
+25 pts 20m
Lists & Arrays medium

Rotate array

Rotate a list right by k positions in place.

arrays in-place
+20 pts 18m
Lists & Arrays medium

Flatten nested list

Yield every integer from an arbitrarily nested list, depth-first.

recursion generators
+25 pts 22m
Lists & Arrays medium

Merge intervals

Merge all overlapping intervals and return a sorted result.

intervals sort
+30 pts 26m
Lists & Arrays medium

Product except self

Return an array where output[i] is the product of all elements except nums[i], without using division.

arrays prefix-sum
+25 pts 20m
Dicts & Sets medium

Group anagrams

Group words that are anagrams of each other.

dict sorting strings
+22 pts 20m
Dicts & Sets medium

Subarray sum equals K

Count the number of contiguous subarrays whose sum equals k.

prefix-sum dict arrays
+28 pts 25m
Functions & Closures medium

Memoize decorator

Implement a @memoize decorator that caches results of a function.

decorators closures caching
+25 pts 20m
Functions & Closures medium

Function composition

Return a function that applies f after g: compose(f, g)(x) == f(g(x)).

functional closures higher-order
+20 pts 18m
OOP & Classes medium

Linked list reversal

Implement a singly linked list and a function to reverse it in place.

linked-list OOP pointers
+28 pts 25m
OOP & Classes medium

Matrix addition operator

Implement a Matrix class that supports + and * operators.

OOP dunder matrix
+22 pts 20m
Data Structures & Algorithms medium

Quicksort

Implement quicksort and return a sorted list.

sorting recursion divide-and-conquer
+25 pts 25m
Data Structures & Algorithms medium

BFS level-order traversal

Return the level-order traversal of a binary tree as a list of lists.

BFS trees queues
+28 pts 25m
Data Structures & Algorithms medium

Coin change (DP)

Find the minimum number of coins to make exactly the target amount.

dp greedy
+30 pts 28m
Data Structures & Algorithms medium

Graph DFS

Return all nodes reachable from a start node via DFS.

graph DFS recursion
+28 pts 25m
Advanced Python medium

Context manager timer

Implement a Timer context manager that records elapsed seconds.

context-manager time
+22 pts 20m
Advanced Python medium

Retry decorator

Implement @retry(times=3) that retries a function on exception.

decorators error-handling
+28 pts 25m
Advanced Python medium

2D Vector dataclass

Implement a Vector2D dataclass with +, -, scalar *, dot product, and magnitude.

dataclass OOP math
+20 pts 18m

Showing 23 challenges · medium