MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / maxDepth

Method maxDepth

TreeMaxDepthBinaryTree.java:2–7  ·  view source on GitHub ↗
(TreeNode root)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int maxDepth(TreeNode root) {
3 if(root==null) return 0;
4 int lh = maxDepth(root.left);
5 int rh = maxDepth(root.right);
6 return 1+Math.max(lh,rh);
7 }
8}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected