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

Showing 11 challenges · Trees & Binary Trees

Trees & Binary Trees — Python coding challenges

What you will find here

This page lists trees & binary trees challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.

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.