Dsa
Binary Search
Medium
Closest Time Search
You're developing a scheduling application that needs to find the closest available time slot based on given appointments. The appointments are represented in 24-hour format as an array of strings. Given a target time, find the closest time slot that is later than or equal to the target time. If there is no such time, return the earliest time from the list. The input consists of a space-separated array of time strings followed by a target time string. Example:
Input:
13:15 14:30 16:00 18:45
15:00
Output:
16:00
Key concepts
binary_searchtimearray
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