We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9af2c94 commit 68d061cCopy full SHA for 68d061c
kth-smallest-element-in-a-bst/printjin-gmailcom.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def kthSmallest(self, root, k):
3
+ self.count = 0
4
+ self.result = 0
5
+ def inorder(node):
6
+ if not node:
7
+ return
8
+ inorder(node.left)
9
+ self.count += 1
10
+ if self.count == k:
11
+ self.result = node.val
12
13
+ inorder(node.right)
14
+ inorder(root)
15
+ return self.result
0 commit comments