Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Kth Grove

Learn
Play
Prove
Problem context and objectives
Mission briefing

Archive pathfinder · Clues branch through a living archive

Explore only the branches that can still contain the answer: The Kth Grove.

Ignoring the parent-child rule turns a focused search into a full maze traversal.

How you win

  1. 1Recognize when Kth smallest in BST matches the clues
  2. 2Keep this true after every move: after each pop, exactly count smallest BST values have been visited in order
  3. 3Reach the result within O(height + k) time and O(height) space

Rules and pressure

  • Target cost: O(height + k) time and O(height) space
  • State rule: after each pop, exactly count smallest BST values have been visited in order
Lesson 1 of 3

Treat every pop as the next sorted rank and stop immediately at k. Lesson questions refer to the original tree and rank.

Connect the left spine, stack top, and rank counter in one scene.

Your call · With stack [5,3,2,1], which value is next in sorted order?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead