GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesKth Smallest Locker

Gamified challenge · In-order traversal

Kth Smallest Locker

tree is a binary search tree of locker numbers in level order with null for a missing spot (TreeNode in code): every locker in a node's left subtree has a smaller number, every locker in its right subtree a bigger one. All numbers are different.

Write kthSmallest(tree, k) (Python: kth_smallest(tree, k)) that returns the number on the k-th smallest locker, counting from 1. k is always between 1 and the number of lockers.

For [5, 3, 6, 2, 4, null, null, 1] and k = 3, the lockers in order are 1, 2, 3, 4, 5, 6, so the answer is 3.

Sign in to play Kth Smallest Locker

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account