Skip to content

Commit 4655b73

Browse files
sangheestylekamyu104
authored andcommitted
update closest-binary-search-tree-value.py (#29)
* update closest-binary-search-tree-value.py make it a bit clear * Update closest-binary-search-tree-value.py
1 parent 4c7749c commit 4655b73

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Python/closest-binary-search-tree-value.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ def closestValue(self, root, target):
1313
while root:
1414
if abs(root.val - target) < gap:
1515
gap = abs(root.val - target)
16-
closest = root
16+
closest = root.val
1717
if target == root.val:
1818
break
1919
elif target < root.val:
2020
root = root.left
2121
else:
2222
root = root.right
23-
return closest.val
24-
23+
return closest

0 commit comments

Comments
 (0)