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
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 easy

Employee Hierarchy

Build an employee hierarchy tree and compute the total number of direct and indirect reports for each employee.

tree dfs graph
+10 pts 15m
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
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
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
Trees & Binary Trees medium

Trim BST to range

Implement a function to trim a BST to only retain nodes with values in a given inclusive range.

bst recursion tree-pruning
+25 pts 25m
Graphs & Graph Algorithms medium

Graph Valid Tree

Determine if n nodes and an edge list form a valid tree (connected and acyclic).

graph dfs bfs
+25 pts 30m

Showing 21 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.