Festival Performances

Greedy Scheduling Algorithms

Festival Performances Problem

During the annual Flower Festival, several performances are scheduled throughout the day. Every performance has a start time and an end time. Attendees want to watch as many performances as possible, but they can't watch overlapping performances.

Task: Write a function that takes a list of performances, where each performance is represented as a pair of integers [start, end], and returns the maximum number of performances an attendee can enjoy without any overlaps.

Example:

For the list of performances:

performances = [[1, 4], [3, 5], [0, 6], [5, 7], [3, 8], [5, 9], [6, 10], [8, 11]]

The optimal solution is to attend the performances: [1, 4], [5, 7], [8, 11] (or any other combination that yields 3 events). Thus, the function should return 3.

Hint: A greedy algorithm that sorts the performances based on their end times can solve this problem efficiently.

Note: You may assume that the performance times are provided in no particular order.