Problem
Imagine you are a busy event organizer tasked with attending as many conference sessions as possible in a single day. Each session has a designated start and end time, and your goal is to attend as many non-overlapping sessions as possible. This involves selecting sessions in such a way that no two sessions overlap, ensuring you make the most of your available time. To solve this problem, follow these steps: 1. List all the sessions with their respective start and end times. 2. Sort the sessions based on their end times. 3. Select the first session that ends the earliest and attend it. 4. For each subsequent session, check if its start time is after the end time of the last attended session. If yes, attend it; if not, skip to the next one. 5. Repeat this process until you have gone through all the sessions. For example, if you have sessions [(1, 4), (3, 5), (0, 6), (5, 7), (8, 9)], you would attend sessions (1, 4), (5, 7), and (8, 9), maximizing your attendance to three sessions. Edge cases to consider include sessions that start and end at the same time or multiple sessions with the same end time.
Input format
The first line contains an integer n, the number of meetings. The next n lines each contain two integers, start and end, representing the start and end times of the meetings.
Output format
Output a single integer, the maximum number of non-overlapping meetings that can be attended.
Constraints
1 <= n <= 10^4; 0 <= start < end <= 10^9;
Sample input
3 1 3 2 4 3 5
Sample output
2