EasyNo. 1450
Number of Students Doing Homework at a Given Time — LeetCode 1450 Python Solution
- Topics
- Array
- Reading time
- 2 min
- Source
- leetcode.com
The problem
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].
Example
- Input
- startTime = [1,2,3], endTime = [3,2,7], queryTime = 4
- Output
- 1
- Explanation
- We have 3 students where:
Python solution
class Solution:
def busyStudent(
self, startTime: List[int], endTime: List[int], queryTime: int
) -> int:
return sum(x <= queryTime <= y for x, y in zip(startTime, endTime))Complexity
- Time
- O(n)where n is the number of students
- Space · auxiliary
- O(1)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0057 | Insert Interval | Medium |
| 0228 | Summary Ranges | Easy |
| 0485 | Max Consecutive Ones | Easy |
| 0665 | Non-decreasing Array | Medium |
| 0674 | Longest Continuous Increasing Subsequence | Easy |
| 0699 | Falling Squares | Hard |
Frequently asked questions
- How hard is LeetCode 1450. Number of Students Doing Homework at a Given Time?
LeetCode 1450. Number of Students Doing Homework at a Given Time is rated Easy on LeetCode.
- What is the time complexity of LeetCode 1450. Number of Students Doing Homework at a Given Time?
The Python solution on this page runs in O(n), where n is the number of students.
- What is the space complexity of LeetCode 1450. Number of Students Doing Homework at a Given Time?
The Python solution on this page uses O(1) auxiliary space.
- What topics does LeetCode 1450. Number of Students Doing Homework at a Given Time cover?
LeetCode 1450. Number of Students Doing Homework at a Given Time is tagged Array on LeetCode.