public class Solution { public int TreeDepth(TreeNode root) { if (root == null) { return 0; } return depth(root); } public int depth(TreeNode root) { if (root == null) { return 0; } int left = depth(root.left); int right = depth(root.right); return Math.max(left, right) + 1; } }