Leetcode Problem 1450. Number of Students Doing Homework at a Given Time

1450. Number of Students Doing Homework at a Given Time

Leetcode Solutions

Iterative Comparison Approach

  1. Initialize a counter to 0 to keep track of the number of students doing homework at queryTime.
  2. Loop through the indices of the startTime and endTime arrays.
    • For each index i, check if startTime[i] <= queryTime and endTime[i] >= queryTime.
    • If both conditions are true, increment the counter by 1.
  3. After the loop, return the counter as the result.
UML Thumbnail

Filter and Count Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...