Kth Smallest Element in BST

Medium

📝 Description

Find the kth smallest element in a binary search tree

Input Format

BST represented as list (level-order) and integer k

Output Format

Kth smallest element

Constraints

1 ≤ k ≤ number of nodes ≤ 10^4

🔍 Sample Input

[5,3,6,2,4,null,null,1]
3
            

✅ Sample Output

3
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run