Skip to content

Instantly share code, notes, and snippets.

@shharma-vipin
Created August 10, 2019 14:28
Show Gist options
  • Save shharma-vipin/e692a82650fcb3b9838b617af3a6091d to your computer and use it in GitHub Desktop.
Save shharma-vipin/e692a82650fcb3b9838b617af3a6091d to your computer and use it in GitHub Desktop.
Maximum Depth Of a Tree
public int maxDepth(TreeNode A) {
if(A == null) return 0;
int left = maxDepth(A.left);
int right = maxDepth(A.right);
return Math.max(left,right)+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment