当前位置:网站首页>[force buckle] maximum depth of binary tree
[force buckle] maximum depth of binary tree
2022-07-19 06:26:00 【Patrick star`】
104. The maximum depth of a binary tree - Power button (LeetCode)
subject :
Given a binary tree , Find out the maximum depth .
The depth of a binary tree is the number of nodes in the longest path from the root node to the farthest leaf node .
explain : A leaf node is a node that has no children
Ideas :
Using preorder traversal , Depth of each recursive layer +1
Code :
int maxDepth(struct TreeNode* root)
{
if(root == NULL)
{
return 0;
}
int ldepth = maxDepth(root->left);// The height of the left subtree
int rdepth = maxDepth(root->right);// The height of the right subtree
return ldepth > rdepth ? ldepth + 1:rdepth + 1;
}边栏推荐
- Antd is not defined
- 谷歌浏览器不能手动修改cookies,cookie报红标红
- 虚拟现实中的眼睛跟踪
- 【力扣】用栈实现队列
- Salgaze: personalized gaze estimation using visual saliency
- 最长括号匹配 (线性DP)
- Simple chrome script automatically skips the charging acknowledgment page after the video playback of station B ends
- Talking about several solutions of cross domain
- Knapsack with dependency, narrow sense (binary enumeration), broad sense (tree DP)
- Chrome browser settings [display the translation language icon in the upper right corner]
猜你喜欢

EOG-based eye movement detection and gaze estimation for an asynchronous virtual keyboard基于EOG的异步虚

索引库中的文档的操作

有线电视网(树上分组)

Salgaze: personalized gaze estimation using visual saliency

Simple chrome script automatically skips the charging acknowledgment page after the video playback of station B ends

Learning video saliency from human gaze using candidate selection

DSL实现Metrics 聚合

Configure the 'log' shortcut key in vscode and remove the console log(‘‘); Semicolon in;

通過VOR深度估計解决三維注視交互中的目標模糊問題

2022/07/09 第五小组 丁帅 学习笔记 day02
随机推荐
本地makefile 编译其他文件夹文件 指定obj目录
Addition and subtraction of busybox date time
Lithium battery charging management chip
SalGaze:使用视觉显著性的个性化注视估计
Antd is not defined
[transfer] Darwin streaming server core code analysis
【力扣】相同的树
Positional change of the eyeball during eye movements: evidence of translational movement
Qtss data type
Basic mathematics course 2_ Euler function, linear sieve, extended Euler
大龄程序员都去哪了?
vscode 使用技巧1
Boost dc/dc converter
自下而上和自上而下的注意力:不同的过程和重叠的神经系统 2014sci
计算几何(2)
[detailed tutorial installation] [configuration] auxiliary plug-ins about eslint in vscode
带透明png转换成c数组
Computational geometry (4.17)
基于运动和视觉突出性的自我视频中的注意预测
js变量提升