Kth smallest element in BST

Write codeMedium20 minMeta style

Your task

Given a binary search tree as a level-order array arr (null for missing) and a 1-indexed integer k, return the value of the k-th smallest element. The tree is a valid BST with distinct values and 1 <= k <= node count. 1 <= node count <= 100000.

Examples

kth_smallest_bst(arr: list[int], k: int) -> int
Example 1
Inputkth_smallest_bst([3, 1, 4, None, 2], 1)
Output1