难度: 简单 标题:二叉树最大深度
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.
思路
root == null时深度为0;最大深度为左/右的最大深度+1;
代码
1 | /** |
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.
root == null时深度为0;最大深度为左/右的最大深度+1;
1 | /** |
Update your browser to view this website correctly. Update my browser now