Advertisement
aero2146

Maximum Depth of Binary Tree

Jan 11th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.18 KB | None | 0 0
  1. class Solution {
  2.     public int maxDepth(TreeNode root) {
  3.         if (root == null) return 0;
  4.        
  5.         return Math.max(1+maxDepth(root.left), 1+maxDepth(root.right));
  6.     }
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement