package org.example.interview.practice; /** * @author xianzhe.ma * @date 2021/11/4 */ public class NC_13_MAX_DEPTH { public int maxDepth (TreeNode root) { // write code here if (root == null) { return 0; } int left = maxDepth(root.left); int right = maxDepth(root.right); return 1 + Math.max(left, right); } public static class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; } }