arrow_back Back to Challenges

#230 Kth Smallest Element in a BST

Medium Acceptance 0%
description

Problem Description

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

checklist Constraints

The number of nodes in the tree is n.
1 <= k <= n <= 10^4
0 <= Node.val <= 10^4

science Examples

Case #1

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

Case #2

In: root = [5,3,6,2,4,null,null,1] k = 3
Out: 3

Mastery Tags

Binary Search Trees

Hiring Companies

Amazon Google Meta
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude