当前位置:Gxlcms >
数据库问题 >
leetcode513 FindBottomLeftTreeValue Java
leetcode513 FindBottomLeftTreeValue Java
时间:2021-07-01 10:21:17
帮助过:26人阅读
int res = 0,h = 0
;
2 public int findBottomLeftValue(TreeNode root) {
3 findBottomLeftValue(root, 1
);
4 return res;
5 }
6 public void findBottomLeftValue(TreeNode root,
int depth) {
7 if(h < depth) {res=root.val; h=
depth;}
8 if(root.left !=
null) findBottomLeftValue(root.left, depth+1
);
9 if(root.right !=
null) findBottomLeftValue(root.right, depth+1
);
10 }
leetcode513 FindBottomLeftTreeValue Java
标签:value java node bsp treenode class root bottom void