Skip to content
RED SAGSkills
hard60 ptsdatesmath

SLA Clock in Business Minutes

A support desk measures response time only during business hours: Monday to Friday, 09:00 to 17:00 UTC, excluding the dates in holidays (YYYY-MM-DD).

startIso and endIso are UTC timestamps like 2024-03-08T16:00:00Z with whole minutes (seconds are always 00). Return the number of business minutes in the interval from start to end. If end is not after start, return 0.

Example 1

Input: startIso = "2024-03-08T16:00:00Z", endIso = "2024-03-11T10:30:00Z", holidays = []
Output: 150
Explanation: One hour on Friday plus 90 minutes on Monday.

Example 2

Input: startIso = "2024-03-09T10:00:00Z", endIso = "2024-03-10T12:00:00Z", holidays = []
Output: 0
Explanation: Saturday to Sunday has no business minutes.

Constraints

  • Both timestamps are between 1971 and 2099
  • The interval spans at most 20 years
  • 0 <= holidays.length <= 500
Hint 1

Work in minutes since the epoch; UTC days start at multiples of 1440.

Hint 2

For each day, intersect [day + 540, day + 1020) with [start, end).

Discussion 0

Join free to post in the discussion.

Good practice for: Backend Developer, Full Stack Developer, Site Reliability Engineer, Data Engineer, Automation Test Engineer

Run checks your code on 3 sample tests. Submit runs all 10 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.