FastPrepEarliest Common Meeting Start

Earliest Common Meeting Start

Visa logoVisa● MediumFULLTIMEOA
Learn

Problem statement

Each row of busy is [person, activity, start, end], where the times use 24-hour HH:MM format. A row makes its person unavailable at every minute from start through end, inclusive.

Return the earliest time at which all listed people can attend for duration consecutive minute slots within the same day. When at least one busy row is present, search begins at the earliest listed start time; an empty calendar begins at 00:00. Overlapping intervals are combined. Return the start as HH:MM, or -1 when no meeting fits.

Function

earliestCommonMeetingStart(busy: String[][], duration: int) → String

Examples

Example 1

busy = [["A","focus","02:00","10:00"],["B","lunch","12:00","12:59"]]duration = 180return = "13:00"

Minute 13:00 begins the first three-hour span after both inclusive busy intervals.

Example 2

busy = [["A","focus","02:00","10:00"],["B","lunch","12:00","12:59"]]duration = 90return = "10:01"

The first busy interval ends at 10:00 inclusive, so the earliest ninety-minute meeting begins at 10:01.

Constraints

  • 0 <= busy.length <= 10000.
  • Every row has four strings; start and end are valid same-day times with start no later than end.
  • 1 <= duration <= 1440.

More Visa problems

See Visa hiring insights
public String earliestCommonMeetingStart(String[][] busy, int duration) {
    // Write your code here.
}
busy[["A","focus","02:00","10:00"],["B","lunch","12:00","12:59"]]
duration180
expected"13:00"
Checking account…