LeetCode-104 Posted on 2020-07-28 Edited on 2025-02-13 In LeetCode 题目 结果 代码12345678class Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1; }} 复杂度时间复杂度:O(n) 空间复杂度:O(n)