def solution(schedules):
    schedules.sort(key=lambda x: (x[1], x[0]))

    count = 0
    end_time = -1

    for start, end in schedules:
        if start >= end_time:
            count += 1
            end_time = end

    return count


schedules = [
    [1, 4],
    [3, 5],
    [0, 6],
    [5, 7]
]

print(solution(schedules))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: