Dsa
Binary Search Tree
Warm-up
Archive Floor Finder
An archive uses a BST to store historical records by year. You need to find the 'Floor' year for a query: the largest year in the archive that is less than or equal to a target year. If no such year exists (all years are greater than the target), output -1.
Input Format:
Line 1: Space-separated integers (insertion order).
Line 2: The target year.
Output Format:
A single integer representing the floor value, or -1.
Example:
Input:
100 50 150 25 75
80
Output:
75
Key concepts
binary_search_treesearchfloor_operation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now