Skip to content

Commit 1a455cd

Browse files
authored
Update Kth Smallest Element in a BST - Leetcode 230.py
1 parent fa58931 commit 1a455cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Kth Smallest Element in a BST - Leetcode 230.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ def dfs(node):
1414
return
1515

1616
dfs(node.left)
17-
count[0] = count[0] - 1
1817

19-
if count[0] == 0:
18+
if count[0] == 1:
2019
ans[0] = node.val
20+
21+
count[0] = count[0] - 1
2122

22-
if k > 0:
23+
if count[0] > 0:
2324
dfs(node.right)
2425

2526
dfs(root)

0 commit comments

Comments
 (0)