Longest Uninterrupted Work Block
Problem statement
You are given meeting intervals for several employees on several workdays. Each row of meetings is [employeeId, day, startMinute, endMinute], where the interval is half-open: the employee is busy from startMinute through endMinute - 1.
For every distinct (employeeId, day) pair appearing in the input, find the longest uninterrupted free block inside the half-open business window [businessStart, businessEnd). Clip meetings to business hours and merge overlapping or touching busy intervals before measuring free time.
Return one string per pair in the form employeeId|day|minutes, sorted first by employeeId and then by day, both lexicographically.
Function
longestWorkBlocks(meetings: String[][], businessStart: int, businessEnd: int) → String[]Examples
Example 1
meetings = [["e1","2026-09-18","540","600"],["e1","2026-09-18","630","690"],["e2","2026-09-18","600","720"]]businessStart = 540businessEnd = 1020return = ["e1|2026-09-18|330","e2|2026-09-18|300"]Employee e1 has free gaps of 30 and 330 minutes. Employee e2 has gaps of 60 and 300 minutes.
Example 2
meetings = [["a","d1","400","550"],["a","d1","540","620"],["a","d1","900","1100"]]businessStart = 480businessEnd = 1020return = ["a|d1|280"]The first two meetings clip and merge into [480,620), while the last clips to [900,1020). The longest free gap is [620,900).
Constraints
1 <= meetings.length <= 100000.- Every row has exactly four strings and identifies a nonempty employee and day.
- Times are decimal integers satisfying
0 <= startMinute < endMinute <= 1440. 0 <= businessStart < businessEnd <= 1440.- Every distinct employee-day pair has at least one row, but all of its rows may lie outside business hours.