Number of Students Doing Homework at a Given Time
Below is the Python code to find the number of students doing their homework at the given queryTime
, considering the startTime
and endTime
for each student.


Explanation:
 Initialize Count: We start by initializing a count variable to keep track of the number of students doing homework at
queryTime
.  Iterate Through Students: We loop through the
startTime
andendTime
arrays to examine each student’s homework time.  Check Time: For each student, we check if
queryTime
falls within their homework interval[startTime[i], endTime[i]]
. If it does, we increment the count.  Return Result: Finally, we return the count, representing the number of students doing their homework at
queryTime
.