terminal
Elevo
/
ESC
Login
Initiate Registration
code
Topics
corporate_fare
Companies
history
History
arrow_back
Back to Challenges
#230
Kth Smallest Element in a BST
Medium
Acceptance 0%
Editorial
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
Python 3
expand_more
C
C++ 17
Java
JavaScript
Python 3
C
C++ 17
Java
JavaScript
Python 3
refresh
class Solution: def kthSmallest(self, root: TreeNode, k: int) -> int: pass
Login to Compile
Processing
terminal
Debug Output
home
Home
extension
Practice
robot_2
login
Sign In
account_circle
Menu
code_blocks
Coding
psychology
Aptitude
Navigation
close
Login
Registration