LeetCode#104 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
分析
这是一道典型的二叉树遍历题目,可以查看之前对于“树的遍历”的介绍。可以选择深度优先搜索递归法解决:
1 |
int (node) |
近期评论