Title description
Problem-solving ideas
- Using recursive thinking, go to the maximum of the maximum depth of the left child and the maximum depth of the right child + 1
Problem-solving code
var maxDepth = function(root) {
if (!root) {
return 0;
}
return Math.max(maxDepth(root.left),maxDepth(root.right)) + 1;
};