1 line Java solution


  • 0
        public boolean isValidBST(TreeNode root) {
            return isValidBST(root, Long.MIN_VALUE, Long.MAX_VALUE);
        }
    
        private boolean isValidBST(TreeNode node, long lowBound, long upperBound) {
            return node == null ? true : node.val > lowBound && node.val < upperBound && isValidBST(node.left, lowBound, node.val) && isValidBST(node.right, node.val, upperBound);
        }
    

  • 0

    Totally not suspicious that a user named "xiangyq" almost immediately upvoted you. And that that user also upvoted your previous topic and that that user was created 11 days ago, just like your previous topic.

    Also, you added four lines.


  • 0

    Lol, that "other" user wasn't just created on the same day but even just five minutes after you posted your topic. Did you want to get caught?


  • 0
    This post is deleted!

  • 0

    @ManuelP sorry I voted for myself with my other account. This won't happen again.


Log in to reply
 

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