Given the root of a binary tree, return its maximum depth — the number of nodes along the longest path from the root down to the farthest leaf.
root = [3,9,20,null,null,15,7]3root = []0Try it now — no sign-up needed. Write your solution in Python or JavaScript, run it against test cases, and submit for a verdict, right in your browser.
Open the editor →A tree is a hierarchical structure where each node has at most a fixed number of children (two, for binary trees). Almost every tree problem reduces to a traversal — decide what order you visit nodes in, and what you do at each one.
Original problem on LeetCode ↗