LeetCode-104

Links:https://leetcode.com/problems/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

如果本节点为空,返回0(同时也是递归的终点)

 

【LeetCode】104.Maximum Depth of Binary Tree
Tagged on:
0 0 投票数
Article Rating
订阅评论
提醒

0 评论
内联反馈
查看所有评论