Skip to main content
LeetCode 94, Easy. Topics: Stack, Tree, Depth-First Search, Binary Tree. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 15 parametrized pytest cases, and a playground notebook:

Problem

Given the root of a binary tree, return the inorder traversal of its nodes’ values.

Examples

Example 1
Example 2

Constraints

  • The number of nodes in the tree is in the range [0, 100]
  • -100 <= Node.val <= 100
Follow up: Recursive solution is trivial, could you do it iteratively?

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode 250, NeetCode All, AlgoMaster 75.
Last modified on August 25, 2026