Watching shows without overlap

Write code · Challenge · §6.3 Greedy

shows holds the schedules of live shows. [s, e] is a show that starts at minute s and ends at minute e. You can watch only one show at a time, and you watch each show you choose from start to finish. A show that starts at the moment another show ends can be watched right after it.

Complete the function solution, which returns the largest number of shows you can watch.

Function

solution(shows)

Constraints

Examples

showsresult
[[1, 3], [2, 5], [4, 6]]2
[[60, 90], [0, 50], [55, 70], [80, 100]]3

Starter code

def solution(shows):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.