FastPrepWait Until the Next Bus
Problems/Wait Until the Next Bus

Wait Until the Next Bus

Visa logoVisa● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report keeps the next-shuttle waiting-time task and the time format but leaves out numeric limits and the function signature. Our version is about 96% the same as the reported question.

You are given a current time and a list of bus departure times for the same service day. Every time is a zero-padded 24-hour string in HH:MM format.

Return the number of minutes until the earliest departure that is at or after the current time. A bus departing exactly now has wait 0. Return -1 if every listed departure has already passed.

Function

nextBusWait(currentTime: String, departures: String[]) → int

Examples

Example 1

currentTime = "09:10"departures = ["08:45","09:30","10:00"]return = 20

The first departure not earlier than 09:10 is 09:30.

Example 2

currentTime = "17:00"departures = ["12:00","17:00","16:30"]return = 0

A departure occurs at the current time.

Constraints

  • 1 <= departures.length <= 10^5.
  • Every time is a valid same-day HH:MM value.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Theme Park Shuttle Wait TimeAirbnb · OAAirbnb interview questions
  • Macaron Order with Set DiscountsShopify · OAShopify interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Lift Total TravelInfosys · OAInfosys interview questions
  • Shell Command Counts with History ReferencesTikTok · OATikTok interview questions
  • Count Dropped RequestsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Recursively Expanded Shell Command CountsHudson River Trading · OAHudson River Trading interview questions
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int nextBusWait(String currentTime, String[] departures) {
      // write your code here
    }
}
Checking account…