Submission Detail

93 / 93 test cases passed.
Status:

Accepted

Runtime: 45 ms
Memory Usage: 21.2 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

10
15
20
25
30
35
40
45
50
55
60
65
1
2
3
4
5
6
7
python
You are here!
Your runtime beats 36.76 % of python submissions.
Runtime (ms)
Distribution (%)

10
15
20
25
30
35
40
45
50
55
60
65
2.5
5.0
7.5
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

18000
18500
19000
19500
20000
20500
21000
10
20
30
40
python
You are here!
Your memory usage beats 19.88 % of python submissions.
Memory (KB)
Distribution (%)

18000
18500
19000
19500
20000
20500
21000
10
20
30
40
Zoom area by dragging across this chart

Invite friends to challenge Kth Smallest Element in a BST


Submitted Code: 0 minutes ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def kthSmallest(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: int
"""
def traverse(root,list_tr):
if (root == None):
return list_tr
list_tr.append(root.val)
list_tr = traverse(root.left,list_tr)
list_tr = traverse(root.right,list_tr)
return list_tr
listt = []
allNodes = traverse(root, listt)
allNodes.sort()
return (allNodes[k-1])
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX