题意以及限制条件
- 题目:
- 限制条件:
想到的所有可能解法
-
Ways_1——递归
- 时间复杂度——O(n);空间复杂度——O(n)。
对应的代码
- Ways_1
class Solution {
public int maxDepth(TreeNode root) {
//Teerminator
if (root == null) return 0;
//Current Logic & Drill Down
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
//Restore Current Data
}
}