Back to problems

Tree Depth Calculation

Algorithm · Netflix · Easy

Given the root of a binary tree, determine the tree's greatest depth. Depth is measured as the count of nodes on the longest route beginning at the root and ending at its most distant leaf. Input: The binary tree's root node; each node stores an integer. Output: Return an integer equal to the maximum depth of the tree. Test Cases: Input: root = [8,4,13,null,null,11,17], Output: 3 Input: root = [6,null,10], Output: 2 Input: root = [], Output: 0 Input: root = [5], Output: 1…

Checking your access…