二叉树的深度
时间限制:1秒
空间限制:32768K
热度指数:122652
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
输入一棵二叉树,求该树的深度。从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。
笔记
收藏
纠错
二叉树的深度
返回全部题目
剑指Offer_编程题
列表加载中...
上一题
下一题
讨论
排行
保存并调试
求助
做题遇到困难?
查看通过的代码
参与大家的讨论
查看编程常见问题
练习模式
切换考试模式,提前熟悉考试环境
练习模式
考试模式
保存并调试之后,这里将会显示运行结果
/** public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { public int TreeDepth(TreeNode root) { } }
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: int TreeDepth(TreeNode* pRoot) { } };
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def TreeDepth(self, pRoot): # write code here
/* public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode (int x) { val = x; } }*/ class Solution { public int TreeDepth(TreeNode pRoot) { // write code here } }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function TreeDepth(pRoot) { // write code here } module.exports = { TreeDepth : TreeDepth };
val = $val; } }*/ function TreeDepth($pRoot) { // write code here }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function TreeDepth(pRoot) { // write code here }