Meetup Schedule π
Updated
Problem statement
A start-up owner wants to meet investors to raise money. Investor i is available from day firstDay[i] to day lastDay[i], and both of those days count. The owner can hold at most one meeting per day, and each investor needs only one meeting. Return the largest number of meetings the owner can hold.
For example, take firstDay = [1, 2, 3, 3, 3] and lastDay = [2, 3, 4, 4, 4]. Only days 1 to 4 are available to anyone, so at most 4 meetings fit, and the answer is 4.
Complete the function maxMeetings in the editor.
maxMeetings has the following parameters:
int[] firstDay: the first day each investor is availableint[] lastDay: the last day each investor is available
The function returns an int: the maximum number of meetings that can be held.
Function
maxMeetings(firstDay: int[], lastDay: int[]) β intExamples
Example 1
firstDay = [1, 2, 3, 3, 3]lastDay = [2, 3, 4, 4, 4]return = 4There are 5 investors, numbered 0 to 4.
- Investor 0 is available on days 1 to 2.
- Investor 1 is available on days 2 to 3.
- Investors 2, 3 and 4 are available on days 3 to 4.
Days 1, 2, 3 and 4 are the only days anyone is free, so at most 4 meetings fit. The owner can reach 4: investor 0 on day 1, investor 1 on day 2, investor 2 on day 3 and investor 3 on day 4. Investor 4 has no free day left, so the answer is 4.
Constraints
1 β€ n β€ 105, wherenis the length offirstDayandlastDay1 β€ firstDay[i] β€ lastDay[i] β€ 109
More WeRide interview questions
Similar questions at other companies
- Maximum Compatible Time WindowsIBM Β· OAIBM interview questions
- Task SchedulingJP Morgan Chase Β· OAJP Morgan Chase interview questions
- Minimum Markers to Clear Line SegmentsHSBC Β· OAHSBC interview questions
- Minimum Machines for TasksExpedia Β· OAExpedia interview questions
- Minimum SegmentsSnowflake Β· OASnowflake interview questions
- Meeting RoomWeWork Β· OAWeWork interview questions
- Most Disjoint Intervals From Starts and DurationsDocuSign Β· OADocuSign interview questions
- University Career FairRoblox Β· OARoblox interview questions
- Minimum RetailersAmazon Β· OA
- Calculate Minimum Satellites RequiredGoogle Β· OAGoogle interview questions