A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Time Complexity: O(N)
Approach,

Implementation,
var maxDepth = function(root) {
if (root === null) return 0
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1
};
Follow me for more…