Skip to content

Commit 9986cf9

Browse files
refactor 98
1 parent c2e6165 commit 9986cf9

File tree

1 file changed

+0
-28
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-28
lines changed

src/main/java/com/fishercoder/solutions/_98.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,4 @@ boolean valid(TreeNode root, Integer min, Integer max) {
4444
}
4545
}
4646

47-
48-
public static class Solution2 {
49-
public boolean isValidBST(TreeNode root) {
50-
if (root == null) {
51-
return true;
52-
}
53-
return dfs(root.left, Long.MIN_VALUE, root.val) && dfs(root.right, root.val, Long.MAX_VALUE);
54-
}
55-
56-
private boolean dfs(TreeNode root, long minValue, long maxValue) {
57-
if (root == null) {
58-
return true;
59-
}
60-
if (root != null && (root.val <= minValue || root.val >= maxValue)) {
61-
return false;
62-
}
63-
boolean leftResult = true;
64-
boolean rightResult = true;
65-
if (root.left != null) {
66-
leftResult = dfs(root.left, minValue, root.val);
67-
}
68-
if (root.right != null) {
69-
rightResult = dfs(root.right, root.val, maxValue);
70-
}
71-
return leftResult && rightResult;
72-
}
73-
}
74-
7547
}

0 commit comments

Comments
 (0)