题目
Given two integer arrays startTime and endTime and given an integer queryTime.
The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.
解题思路
遍历每个学生开始和结束做作业的时间,判断是否包含查询时刻
代码
class Solution:
def busyStudent(self, startTime: List[int], endTime: List[int], queryTime: int) -> int:
res = 0
for s, e in zip(startTime, endTime):
if s <= queryTime <= e:
res += 1
return res