diff --git a/java/Chapter 4/Question4_5/QuestionB.java b/java/Chapter 4/Question4_5/QuestionB.java index 1fe88b75..8dd1d0e3 100644 --- a/java/Chapter 4/Question4_5/QuestionB.java +++ b/java/Chapter 4/Question4_5/QuestionB.java @@ -11,11 +11,7 @@ public static boolean checkBST(TreeNode n, Integer min, Integer max) { if ((min != null && n.data <= min) || (max != null && n.data > max)) { return false; } - if (!checkBST(n.left, min, n.data) || - !checkBST(n.right, n.data, max)) { - return false; - } - return true; + return checkBST(n.left, min, n.data) && checkBST(n.right, n.data, max); } public static boolean checkBST(TreeNode n) {