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 challengesFloor & Ceiling Prices

Gamified challenge · BST descent

Floor & Ceiling Prices

tree is a binary search tree of different positive prices in level order with null for a missing spot (TreeNode in code): smaller prices to the left, bigger to the right. budget is a positive integer.

Write floorCeil(tree, budget) (Python: floor_ceil(tree, budget)) that returns [floor, ceiling]: the floor is the highest price <= budget, the ceiling the lowest price >= budget. Use -1 for one that doesn't exist.

For [8, 4, 12, 2, 6, 10, 14]: a budget of 5 gives [4, 6], 10 gives [10, 10], and 1 gives [-1, 2].

Sign in to play Floor & Ceiling Prices

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