CodeOath
← All problems

Kth Smallest Element in a BST

Medium
treesbinary-search-tree

Given the root of a binary search tree and an integer k, return the k-th smallest value (1-indexed) among all the node values in the tree.

Trees in this problem are given as a level-order array: null marks a missing child, and trailing nulls are omitted.

Example:

Input: root = [3,1,4,null,2], k = 1
Output: 1