Largest Number of One-Day Event Attendances

Quick Overview

Largest Number of One-Day Event Attendances. Event[start,end] may be attended on any one integer day in its inclusive interval.

Largest Number of One-Day Event Attendances

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Event[start,end] may be attended on any one integer day in its inclusive interval. Attend at most one event per day and each event at most once. Return the greatest number of events that can be attended. ```cpp class Solution { public: int maxEvents(vector<vector<int>>& events); }; ``` ### Examples **Example 1:** ```text Input: events = [[1,1],[1,2],[2,2]] Output: 2 Explanation: Only days1 and2 are available, and two of the three events can be assigned to them. ``` **Example 2:** ```text Input: events = [[4,4],[1,1],[2,3]] Output: 3 Explanation: Attend the second event on1,the third on2,and the first on4. ``` ### Constraints - There are 1 to 100000 events, each a two-entry interval. - `1 <= startDay <= endDay <= 100000`. ### Contract considerations Intervals describe possible attendance days, not an obligation to remain for the whole interval. ```hint Read the boundary condition Check coincident event dates and inclusive endpoints. A valid attendance plan uses each event and each day at most once. ``` ### Boundary reminders Intervals describe possible attendance days, not an obligation to remain for the whole interval.

Overview: Largest Number of One-Day Event Attendances. Event[start,end] may be attended on any one integer day in its inclusive interval.

Microsoft logo
Microsoft
Source window: 0–6 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Event[start,end] may be attended on any one integer day in its inclusive interval. Attend at most one event per day and each event at most once. Return the greatest number of events that can be attended.

class Solution {
public:
    int maxEvents(vector<vector<int>>& events);
};

Examples

Example 1:

Input: events = [[1,1],[1,2],[2,2]]
Output: 2
Explanation: Only days1 and2 are available, and two of the three events can be assigned to them.

Example 2:

Input: events = [[4,4],[1,1],[2,3]]
Output: 3
Explanation: Attend the second event on1,the third on2,and the first on4.

Constraints

  • There are 1 to 100000 events, each a two-entry interval.
  • 1 <= startDay <= endDay <= 100000 .

Contract considerations

Intervals describe possible attendance days, not an obligation to remain for the whole interval.

Boundary reminders

Intervals describe possible attendance days, not an obligation to remain for the whole interval.