Skip to content

Commit 8ff95dd

Browse files
committed
Runtime: 86 ms (Top 42.71%) | Memory: 18.1 MB (Top 15.27%)
1 parent 1df2589 commit 8ff95dd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# Runtime: 86 ms (Top 42.71%) | Memory: 18.1 MB (Top 15.27%)
2+
13
# Definition for a binary tree node.
24
# class TreeNode:
3-
# def __init__(self, val=0, left=None, right=None):
4-
# self.val = val
5-
# self.left = left
6-
# self.right = right
5+
# def __init__(self, val=0, left=None, right=None):
6+
# self.val = val
7+
# self.left = left
8+
# self.right = right
79
class Solution:
810
def kthSmallest(self, root: Optional[TreeNode], k: int) -> int:
911
n=0
@@ -14,7 +16,7 @@ def kthSmallest(self, root: Optional[TreeNode], k: int) -> int:
1416
stack.append(cur)
1517
cur=cur.left
1618
cur=stack.pop() # pop the most recent element which will be the least value at that moment
17-
n+=1
19+
n+=1
1820
if n==k:
1921
return cur.val
20-
cur=cur.right
22+
cur=cur.right

0 commit comments

Comments
 (0)