3169. 无需开会的工作日
题目链接 | 3169. 无需开会的工作日 |
---|---|
思路 | 排序 |
题解链接 | Wiki |
关键点 | 无 |
时间复杂度 | \(O(n\log n)\) |
空间复杂度 | \(O(1)\) |
代码实现:
class Solution:
def countDays(self, days: int, meetings: List[List[int]]) -> int:
meetings.sort()
answer = 0
last = 0
for start, end in meetings:
if last < start:
answer += start - last - 1
last = max(last, end)
answer += days - last
return answer