Skip to content

Commit

Permalink
fix: fixes is binary search tree problem
Browse files Browse the repository at this point in the history
  • Loading branch information
leometzger committed Aug 17, 2023
1 parent 41cf50e commit cb75bb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions datastructures/is_binary_search_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func checkLeft(root *TreeNode, maxAllowed int32) bool {
return true
}

if root.data > maxAllowed {
if root.data >= maxAllowed {
return false
}

Expand All @@ -17,7 +17,7 @@ func checkRight(root *TreeNode, minAllowed int32) bool {
return true
}

if root.data < minAllowed {
if root.data <= minAllowed {
return false
}

Expand All @@ -38,7 +38,7 @@ func checkBST(root *TreeNode) bool {
}

return checkLeft(root.left, root.data) &&
checkBST(root.left) &&
checkRight(root.right, root.data) &&
checkBST(root.left) &&
checkBST(root.right)
}

0 comments on commit cb75bb5

Please sign in to comment.