Kth Smallest Element in BST
Medium
Trees
Tree
DFS
BST
Find kth smallest element in BST given as level-order.
Constraints
1 ≤ k ≤ n ≤ 10^4
Examples
Example 1:
Input: 3 1 4 null 2
1
Output: 1
Example 2:
Input: 5 3 6 2 4 null null 1
3
Output: 3
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console