15% off all plans & roadmaps Use code
See plansLeetCode 94 · Solution & editorial
Given the root of a binary tree, return the inorder traversal of its nodes' values.
Binary Tree Inorder Traversal is a Tree Traversal Patterns (DFS & BFS) problem, in the Recursive Inorder Traversal subpattern. The pattern covers preorder, inorder, level order traversal, LCA, and serialization
Master inorder traversal for BST validation and kth element problems. Produces sorted order in BST.
The reference solution runs in O(n) time and O(1) space.
Binary Tree Inorder Traversal has been reported in interviews at Microsoft, Facebook, Oracle, Amazon, Google.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Binary Tree Inorder Traversal is a Tree Traversal Patterns (DFS & BFS) problem, in the Recursive Inorder Traversal subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.