Coding Challenge

Kth Smallest Element in a BST

Medium
treebstinorder

Find the kth smallest value in a BST.

Given the root of a binary search tree and an integer k, return the kth smallest node value.

Examples

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

Output: 1

Constraints

  • 1 <= k <= number of nodes

Preparing your coding workspace...