Practice Arena

Python Coding Challenges

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

467 challenges 330 easy 120 medium 17 hard
Python Basics medium

Fibonacci(n)

Return the nth Fibonacci number efficiently.

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

Find all anagrams

Return all starting indices where any anagram of a given word appears as a substring.

anagrams strings sliding-window
+20 pts 20m
Strings & Text medium

Substring Anagrams

Return all start indices in a string where a substring of length k is an anagram of a pattern string.

strings sliding-window hash-map
+20 pts 25m
Strings & Text medium

Longest Palindrome Substring

Given a string s, return the longest substring that reads the same forwards and backwards.

strings palindrome substring
+20 pts 25m
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
Lists & Arrays medium

Product of All Except Zeros Handling

Given a list of integers, return a list where each element is the product of all other elements, handling zeros correctly.

product arrays zero-handling
+20 pts 25m
Lists & Arrays medium

Partition around a pivot value

Implement an in-place partition of a list around a given pivot value, returning the boundary index.

lists partition two-pointer
+20 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
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

Graph DFS

Return all nodes reachable from a start node via DFS.

graph DFS recursion
+28 pts 25m
Data Structures & Algorithms medium

Find Peak Element

Implement a function that returns the index of any peak element in an integer array.

arrays search binary-search
+20 pts 25m
Data Structures & Algorithms medium

Merge Sort

Implement merge_sort(numbers) that returns a sorted copy of the input list using the merge sort algorithm.

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

Path Sum II All Paths

Return all root-to-leaf paths where the sum of node values equals a target.

binary-tree dfs backtracking
+20 pts 25m
Data Structures & Algorithms medium

Redundant Connection

Given a list of edges forming a tree plus one extra edge, return the edge that appears last in the input and creates a cycle.

graphs union-find cycle-detection
+25 pts 25m
Decorators & Context Managers medium

Memoize with TTL

Implement a decorator that caches function results for a limited time, returning cached values within the TTL and recomputing after expiry.

decorators memoization caching
+20 pts 20m
Bit Manipulation medium

Bitwise AND of a Range

Given a range [a, b], return the bitwise AND of all integers in that inclusive range without iterating over all numbers.

bitwise range optimization
+20 pts 15m
Dynamic Programming medium

Kadane Variant: Maximum Product Subarray

Implement max_product_subarray(nums) that returns the maximum product of any contiguous subarray.

kadane subarray product
+30 pts 25m
Dynamic Programming medium

Perfect Squares Sum

Given a positive integer n, return the least number of perfect squares (e.g., 1, 4, 9, 16, ...) that sum to n.

dynamic-programming math optimization
+25 pts 25m
Dynamic Programming medium

Longest Arithmetic Subsequence

Given a list of integers, return the length of the longest arithmetic subsequence (constant difference) within it.

dp subsequence hashmap
+30 pts 25m
Trees & Binary Trees medium

Binary tree left side view

Given a binary tree, return the leftmost node's value at each depth, from top to bottom.

binary-tree levels bfs
+20 pts 20m
Trees & Binary Trees medium

Delete Node in BST

Implement a function that deletes a key from a binary search tree and returns the new root.

binary-search-tree tree-traversal recursion
+20 pts 20m
Graphs & Graph Algorithms medium

Articulation Points

Implement a function that returns the articulation points of an undirected graph.

graphs dfs bridges
+25 pts 30m
Graphs & Graph Algorithms medium

Bridges in Graph

Implement a function that returns all bridges in an undirected graph.

graph dfs bridges
+30 pts 30m
Graphs & Graph Algorithms medium

Course Schedule Can Finish

Given numCourses and prerequisites, return whether all courses can be finished without cyclic dependencies.

graph cycle topological
+25 pts 30m
Graphs & Graph Algorithms medium

All Paths from Source to Target

Given a directed acyclic graph, return all paths from node 0 to the last node.

graph dfs backtracking
+25 pts 25m
Recursion & Backtracking medium

Combination Generator

Write a recursive function that returns all combinations of length k from a list of distinct integers.

recursion backtracking combinations
+25 pts 25m
Heaps & Priority Queues medium

Top K Frequent Elements

Given an integer array and a number k, return the k most frequent elements using a heap-based approach.

heap frequency counting
+25 pts 25m
Matrix & 2D Arrays medium

Spiral Matrix Order

Given a 2D matrix, return all elements in clockwise spiral order starting from the top-left.

matrix spiral traversal
+25 pts 25m
Matrix & 2D Arrays medium

01 Matrix Nearest Zero

Given a binary matrix, return a matrix of the same shape where each cell contains the Manhattan distance to the nearest 0.

matrix bfs distance
+25 pts 30m

Showing 31 challenges · medium

Guide: free Python coding challenges

Practice Python by solving problems

PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.

How to use the arena

  1. Pick a category — basics, algorithms, strings, and more
  2. Open a challenge, read the statement, and edit the starter code
  3. Run tests, fix failures, then try a related quiz or tutorial lesson

Challenges vs tutorials and quizzes

Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.