Skip to main content
mediumBlind 75

Kth Smallest Element in a BST

Return the kth smallest value in the BST (1-indexed) Example: [3,1,4,null,2], k=1 => 1

Kth Smallest Element in a BST is a traversal problem: the hard part is modeling the state you visit. Interviewers love it because it reveals your traversal modeling and your edge-case discipline. Once your traversal structure is solid, you can reuse it across dozens of problems.

BFS / DFSTrees

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Kth Smallest Element in a BSTmedium