Kth Smallest Element in a Binary Search Tree

Given the root of a BST and an integer k, return the kth smallest value in the tree, where k is 1-indexed.

Do not sort all node values. Stop traversal as soon as the kth value is found.

Follow-u...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: