Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit bdc1dc5

Browse files
aQuaaQua
authored andcommitted
783 finish
1 parent 556a7d4 commit bdc1dc5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Algorithms/0783.minimum-distance-between-bst-nodes/minimum-distance-between-bst-nodes.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ type TreeNode = kit.TreeNode
1717

1818
func minDiffInBST(root *TreeNode) int {
1919
res := 1<<63 - 1
20-
pre := -1
20+
pre := 1>>63
21+
null := pre
22+
2123
var helper func(*TreeNode)
2224
helper = func (root *TreeNode) {
2325
if root.Left != nil {
2426
helper(root.Left)
2527
}
2628

27-
if pre <0{
29+
if pre != null{
2830
res = min(res, root.Val-pre)
2931
}
3032

@@ -34,6 +36,7 @@ func minDiffInBST(root *TreeNode) int {
3436
helper(root.Right)
3537
}
3638
}
39+
3740
helper(root)
3841

3942
return res

0 commit comments

Comments
 (0)