Maximum Meetings from Start Times and Durations
Updated
Problem statement
Meeting i starts at start[i] and has duration duration[i]. Its finish time is start[i]+duration[i]. Return the maximum number of meetings one person can attend in full.
For this exercise, a selected meeting must start strictly after the previous selected meeting finishes. Equality is not allowed: intervals sharing an endpoint cannot both be selected. All durations are positive. You may select meetings in any order that obeys this rule.
Return 0 for empty input. Return only the maximum count, and leave both input arrays unchanged.
Function
maxMeetings(start: int[], duration: int[]) → intExamples
Example 1
start = [1,3,0,5,8,5]duration = [1,1,6,2,1,4]return = 4The intervals are [1,2],[3,4],[0,6],[5,7],[8,9],[5,9]. Selecting indices 0,1,3,4 gives four compatible meetings. Exhaustive subset review confirms no fifth can be added.
Example 2
start = [1,3,5]duration = [2,2,2]return = 2The intervals are [1,3],[3,5],[5,7]. Neighboring intervals touch and cannot both be selected. Choosing the first and third is valid because 5>3, so the maximum count is 2.
Constraints
- For this exercise, assume 0 <= start.length <= 2000.
- For this exercise, assume 0 <= duration.length <= 2000.
- start and duration have equal length.
- Every start time is between 0 and 1000000, inclusive.
- Every duration is between 1 and 1000000, inclusive.
More Morgan Stanley Online Assessment questions
- Three-Resource 0/1 KnapsackOA · Seen Sep 2026
- Maximum Concurrent ProcessesOA · ONSITE INTERVIEW · Seen Sep 2026
- Maximum Total of Nonadjacent RatingsOA · Seen Jul 2026
- Count Shipment SchedulesOA · Seen Apr 2026
- Delete and EarnOA · Seen Apr 2026
- Interleave Array HalvesOA · Seen Apr 2026
- Get Patch SequenceOA · Seen Feb 2025
- String Subsequences 🐳OA · Seen Mar 2024
- Binary Tree Level OrderOA · Seen Feb 2024
- Merge IntervalsOA · Seen Feb 2024
Similar questions at other companies
- Minimum Satellite Data Transfer IterationsHSBC · OAHSBC interview questions
- Minimum Cost to Select People for Skill QuotasVisa · OAVisa interview questions
- Get Maximum EventsAmazon · OA
- Maximize Wall HitsOpenAI · OAOpenAI interview questions
- Find Niceness 🌺Goldman Sachs · OAGoldman Sachs interview questions
- Maximum Length Pair ChainInMobi · ONSITE INTERVIEWInMobi interview questions
- Find Minimum TimeAlphaSense · OA
- Find Minimum TimeBlackRock · OABlackRock interview questions
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
Interview reports that mention this question
Morgan Stanley interview experiences
- Morgan Stanley New Grad Technology Analyst: 2 Experiences
- Morgan Stanley Intern Oldest Loops: 5 Experiences (Part 5 of 5)
- Morgan Stanley Intern OOP Loops: 5 Experiences (Part 4 of 5)
- Morgan Stanley Intern Earlier Loops: 5 Experiences (Part 3 of 5)
- Morgan Stanley Intern Tech Rounds: 5 Experiences (Part 2 of 5)