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
Lists & Arrays easy

Insert into a Sorted List

Implement a function that inserts a value into a sorted list at the correct position using binary search.

lists binary-search insertion
+10 pts 10m
Data Structures & Algorithms easy

Binary search

Return the index of target in a sorted list, or -1 if not present.

searching binary-search
+12 pts 12m
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 hard

Longest increasing subsequence

Return the length of the longest strictly increasing subsequence.

dp binary-search LIS
+45 pts 40m
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 hard

Median of Two Sorted Arrays

Given two sorted arrays, return the median of the combined sorted array in O(log(min(n,m))) time.

median binary search arrays
+45 pts 40m
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

Shortest Path in Binary Matrix

Implement BFS to find the shortest path length from (0,0) to (n-1,n-1) in an n x n binary matrix, moving through 0 cells in 8 directions.

bfs grid shortest-path
+30 pts 30m
Iterators & Generators easy

Tree inorder generator

Write a generator function that yields a binary tree's node values in inorder traversal.

generator inorder binary-tree
+10 pts 15m
Math & Number Theory easy

Integer Square Root Floor

Implement a function that returns the greatest integer whose square is ≤ n, using only integer operations.

math binary-search integer
+8 pts 12m
Bit Manipulation easy

Count Set Bits

Implement a function that returns the number of set bits (1s) in the binary representation of a non-negative integer.

bit-manipulation binary counting
+10 pts 15m
Bit Manipulation easy

Gray Code Decode

Implement gray_decode(n) that converts an n-bit Gray code integer back to its standard binary value using XOR accumulation.

gray-code bit-manipulation xor
+10 pts 15m
Bit Manipulation easy

Compress Bits Run

Write a function that compresses a binary string by representing consecutive identical bits as a count-bit pair.

bit-manipulation strings compression
+10 pts 15m
Bit Manipulation easy

Sparse Number Check

Check if a non-negative integer is sparse, meaning its binary representation contains no adjacent 1 bits.

bitwise binary conditionals
+10 pts 15m
Dynamic Programming medium

Maximal square

Given a 2D binary matrix of 0s and 1s, compute the area of the largest square containing only 1s.

dynamic-programming matrix maximal-square
+30 pts 30m
Trees & Binary Trees easy

Binary Search Tree Class

Build a BinarySearchTree class and a sequence runner that executes a list of operations.

binary-search-tree classes traversal
+10 pts 15m
Trees & Binary Trees easy

Binary Tree Inorder Traversal

Implement an inorder traversal function that returns node values in left-root-right order.

binary-tree traversal recursion
+10 pts 15m
Trees & Binary Trees easy

Preorder Traversal

Implement a function that returns the preorder traversal values of a binary tree.

binary-tree traversal recursion
+10 pts 10m
Trees & Binary Trees easy

Postorder Traversal

Implement a function that returns the postorder traversal of a binary tree as a list of node values.

binary-tree traversal recursion
+10 pts 15m
Trees & Binary Trees easy

Maximum depth of tree

Implement max_depth(root) to return the maximum depth of a binary tree.

binary-tree recursion depth
+10 pts 15m
Trees & Binary Trees easy

Minimum Depth of Tree

Given a binary tree, compute the minimum depth from the root to the nearest leaf node.

binary-tree depth traversal
+10 pts 15m
Trees & Binary Trees easy

Symmetric Tree Check

Write a function that checks whether a binary tree is symmetric (a mirror of itself).

binary-tree recursion mirror
+10 pts 15m
Trees & Binary Trees easy

Same Tree Check

Write a function that checks whether two binary trees are identical in structure and node values.

binary tree recursion tree traversal
+10 pts 15m
Trees & Binary Trees medium

Lowest Common Ancestor in a Binary Tree

Implement a function to find the lowest common ancestor (LCA) of two nodes in a binary tree.

binary-tree dfs recursion
+30 pts 30m
Trees & Binary Trees medium

Sum Root to Leaf Numbers

Given the root of a binary tree, compute the total sum of all root-to-leaf numbers.

binary-tree dfs recursion
+25 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

Vertical Order Traversal

Compute the vertical order traversal of a binary tree, grouping nodes by column and row.

binary-tree bfs dictionary
+20 pts 25m
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
Trees & Binary Trees easy

Insert into BST

Implement insertion into a Binary Search Tree while maintaining BST properties.

binary-search-tree recursion tree
+10 pts 15m
Binary Search medium

Search in Rotated Array

Implement an efficient search in a rotated sorted array using modified binary search.

binary-search arrays search
+20 pts 20m
Binary Search medium

Interpolation Search

Implement interpolation search in Python on a sorted list of integers.

search sorted-array binary-search
+25 pts 25m
Binary Search medium

Ternary Search

Implement ternary search to locate the maximum of a discrete unimodal function.

ternary-search binary-search unimodal
+25 pts 30m
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 33 challenges

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.