Theme Park Shuttle Wait Time
Updated
Problem statement
Given the shuttle timetable shuttle_times and the time right now current_time, return how long you need to wait until the next shuttle arrives, as a string in HH:MM format. If no more shuttles will arrive today, return "-1".
You are visiting a theme park with a special shuttle that takes guests around the park. Each string in shuttle_times is a time during the day when the shuttle arrives at your location. The times are in chronological order.
All times use a 24-hour clock.
Note: a shuttle leaves the moment it arrives. A shuttle scheduled earlier than current_time has already left, but one scheduled exactly at current_time can still be caught.
Note: you do not need the fastest possible solution. A solution with time complexity no worse than O(shuttle_times.length × MINUTES_IN_DAY) runs within the time limit, where MINUTES_IN_DAY is 1440.
Function
solution(shuttle_times: String[], current_time: String) → StringExamples
Example 1
shuttle_times = ["12:30","14:00","19:55"]current_time = "14:30"return = "05:25"Since the shuttle at "14:00" has already departed, the next arrival is at "19:55". The waiting time from "14:30" to "19:55" is "05:25".
Example 2
shuttle_times = ["12:30","14:00","19:55"]current_time = "20:00"return = "-1"There are no shuttles left for today, so the answer is "-1".
Example 3
shuttle_times = ["12:30","14:00","19:55"]current_time = "14:00"return = "00:00"The next shuttle comes right at current_time, so the wait is "00:00".
Constraints
3 <= shuttle_times.length <= 100- Each
shuttle_times[i]is formatted asHH:MM, from"00:00"to"23:59". shuttle_timesis in chronological order.current_timeis formatted asHH:MM, from"00:00"to"23:59".
More Airbnb Online Assessment questions
- Bouncing DiagonalsOA · Seen Dec 2026
- Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
- Garden Sprinkler PlacementOA · Seen Dec 2026
- Count Card Duel RoundsOA · Seen Nov 2026
- Count Lamps Lighting Each PointOA · Seen Nov 2026
- Simulate Orchard Rot SpreadOA · Seen Nov 2026
- Sort Adjacent PairsOA · Seen Nov 2026
- In-Memory File SystemOA · Seen Nov 2026
- Task Management SystemOA · Seen Nov 2026
- Recipe Management SystemOA · Seen Nov 2026
Similar questions at other companies
- REST API: Highest International StudentsRippling · OARippling interview questions
- Count Invalid Log GroupsIBM · OAIBM interview questions
- Filter Transaction Logs and Calculate Reliability MetricsStripe · OAStripe interview questions
- Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
- Slowest Key PressRoblox · OARoblox interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Best TV Show in a GenreAdyen · OAAdyen interview questions
- Cheating CodemakerJane Street · OAJane Street interview questions
- Correct Apartment Bedroom CountsRamp · OARamp interview questions
- Reflow and Fully Justify Text LinesIntuit · OAIntuit interview questions
Airbnb interview experiences
- Airbnb OA · November 2026
- Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
- Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
- Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
- Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
- Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)