Skip to content

Commit 95106c4

Browse files
authored
Create number-of-students-doing-homework-at-a-given-time.cpp
1 parent 2f9739a commit 95106c4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int busyStudent(vector<int>& startTime, vector<int>& endTime, int queryTime) {
7+
int result = 0;
8+
for (int i = 0; i < startTime.size(); ++i) {
9+
if (startTime[i] <= queryTime && queryTime <= endTime[i]) {
10+
++result;
11+
}
12+
}
13+
return result;
14+
}
15+
};

0 commit comments

Comments
 (0)