Earliest Time to Schedule a Meeting
Updated
Problem statement
You are given an array of strings schedules. Each string has the form "<name> <activity> <start> <end>", for example "Alex work 01:00 13:30". It means that the person name is busy with activity from start to end, and both endpoints are included. Times use the 24-hour HH:MM format. One person can have several entries, and the entries can belong to different people. You are also given an integer k, the meeting length in minutes.
A day is made of the minutes 00:00, 00:01, ..., 23:59. An entry blocks every minute from start through end. A meeting of length k that starts at minute s uses the k minutes s, s + 1, ..., s + k - 1. It must start and finish on the same day, so its last minute is 23:59 at the latest.
Everyone who appears in schedules must attend, so no minute of the meeting can be blocked by any entry. Return the earliest possible start time as a string in HH:MM format, or "-1" if no start time works.
Function
earliestMeetingTime(schedules: String[], k: int) → StringExamples
Example 1
schedules = ["Alex work 01:00 13:30","Sam sleep 00:00 08:00","Alex lunch 13:46 14:00"]k = 15return = "13:31"Together the entries block 00:00 through 13:30 (Sam's sleep overlaps Alex's work), then 13:46 through 14:00. Because 13:30 itself is blocked, the first free minute is 13:31. The minutes 13:31 through 13:45 are exactly 15 free minutes, so the meeting starts at "13:31".
Example 2
schedules = ["Alex work 01:00 13:30","Sam sleep 00:00 08:00","Alex lunch 13:46 14:00"]k = 16return = "14:01"The gap from 13:31 through 13:45 has only 15 minutes, one too few. The next free minute after Alex's lunch is 14:01, and the rest of the day is free, so the answer is "14:01".
Example 3
schedules = ["Ana meeting 00:00 23:00"]k = 60return = "-1"The only free minutes are 23:01 through 23:59, which is 59 minutes. A 60-minute meeting would have to end after 23:59, so no start time works and the answer is "-1".
Constraints
1 <= schedules.length <= 10^4- Each
schedules[i]isname,activity,start, andendseparated by single spaces. nameandactivityeach have1to10English letters.startandendare valid times from00:00to23:59inHH:MMformat, andstartis not later thanend.1 <= k <= 1440
More Microsoft Online Assessment questions
- Minimum Cost to Process Priority TasksOA · Seen Nov 2026
- Most Visited Sprint MarkerOA · Seen Nov 2026
- Maximum Escape Game ScoreOA · Seen Nov 2026
- Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
- Maximum Interactive Team SizeOA · Seen Nov 2026
- Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026
- Minimum Cost K-Capable ModelsOA · Seen Nov 2026
- Find Available Meeting RoomsOA · Seen Oct 2026
- Maximum Sum of a K-StarOA · Seen Oct 2026
- Capacity to Ship Packages Within DaysOA · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
- Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
- Earliest Common Meeting StartVisa · OAVisa interview questions
- Smallest Most-Lit Street PositionHudson River Trading · OAHudson River Trading interview questions
- Most Visited Sprint MarkerChubb · OAChubb interview questions
- Earliest Common Meeting TimeZipRecruiter · OAZipRecruiter interview questions
- File Download Coverage PercentagePersona · OAPersona interview questions
- Stars Between Bars in RangesExpedia · OAExpedia interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
Microsoft interview experiences
- Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
- Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
- Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
- Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
- Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
- Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)