Maximum Depth of Binary Tree | Facebook, Amazon, Linkedin interview question | Leetcode 104
Time: O(N) Space: O(h) (height of the tree) Also check if the below code makes it easier for you to understand... level +=1; int left=maxDepth(root.left); int right=maxDepth(root.right); return Math.max(left,right)
Time: O(N) Space: O(h) (height of the tree) Also check if the below code makes it easier for you to understand... level +=1; int left=maxDepth(root.left); int right=maxDepth(root.right); return Math.max(left,right)