Skip to content
C

Kth Smallest Element in BST

Mediumjavapythonccppjavascript

Given a Binary Search Tree and an integer K, find the K-th smallest value (1-indexed).

Input Format

The first line contains an integer M. The second line contains M space-separated tokens (integers or null) — the BST in level order. The third line contains the integer K.

Output Format

Print the K-th smallest value.

Input (stdin)

Output

Run your code to see output here...