1 class Solution: 2 def maxEvents(self, events: 'List[List[int]]') -> int: 3 events.sort(key=lambda item: (item[1], item[0])) 4 days = set() 5 for start, end in events: 6 if start not in days: 7 days.add(start) 8 else: 9 i = start + 1 10 while i in days and i <= end: 11 i += 1 12 if i <= end: 13 days.add(i) 14 return len(days)
算法思路:贪心法。