Problem Statement: Smart Home Event Scheduler
In a smart home automation system, a user wants to schedule multiple events such as turning on lights, adjusting the thermostat, or starting the coffee machine. Each event has a start time and end time. The system can only handle one event at a time.
You are tasked with implementing a scheduler that calculates the maximum number of non-overlapping events that can be scheduled.
Input Format:
- An integer
n
— the number of events. n
lines follow, where each line contains two integersstart
andend
:start
— the start time of the event (inclusive).end
— the end time of the event (exclusive).
Output Format:
- An integer representing the maximum number of non-overlapping events that can be scheduled.
Constraints:
Sample Input:
Sample Output:
Explanation:
The maximum number of non-overlapping events are:
- Event 1: [1, 3]
- Event 4: [8, 10]
- Event 2: [3, 6]
Test Cases:
Test Case 1:
Input:
Output:
Test Case 2:
Input:
Output:
Test Case 3:
Input:
Output:
Python Code:
Comments
Post a Comment