Java 2 line Solution


  • 0
    G

    
    public boolean hasPathSum(TreeNode r, int s) {
            if ( r == null ) return false;
            return ( s-r.val == 0 && r.left == null && r.right == null ) || hasPathSum(r.left, s-r.val) || hasPathSum(r.right, s-r.val); 
        }
    


Log in to reply
 

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