Why doesn't this work for ALL CASES!?

  • 0
    public class Solution {
        public static int val = 0;
        public int findBottomLeftValue(TreeNode root) {
           return helper(root,false);
        private int helper(TreeNode root, boolean isLeft){
            if(root == null) return val;
            if(isLeft && root != null) val = root.val;
            if(root.left != null) helper(root.left, true);
            if(root.right != null) helper(root.right, false);
            return val;

Log in to reply

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