标签:value java node bsp treenode class root bottom void
1、递归算法 很好理解
1 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
原文地址:http://www.cnblogs.com/LoveBell/p/6437398.html