Shortest Java Solution


  • 0
    N
    • ...
      class Solution {
      int val,height;
      public int findBottomLeftValue(TreeNode root) {
      leftmost(root,1);
      return val;
      }

      public void leftmost(TreeNode root,int length){
      if(length >height){
      height = length;
      val = root.val;
      }
      if(root.left != null)
      leftmost(root.left,length+1);
      if(root.right !=null)
      leftmost(root.right,length+1);
      }
      }
      ...


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.