1450. Number of Students Doing Homework at a Given Time Easy

@problem@discussion
#Array



1/**
2 * [1450] Number of Students Doing Homework at a Given Time
3 *
4 * Given two integer arrays startTime and endTime and given an integer queryTime.
5 * The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
6 * 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.
7 *  
8 * Example 1:
9 * 
10 * Input: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4
11 * Output: 1
12 * Explanation: We have 3 students where:
13 * The first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.
14 * The second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.
15 * The third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.
16 * 
17 * Example 2:
18 * 
19 * Input: startTime = [4], endTime = [4], queryTime = 4
20 * Output: 1
21 * Explanation: The only student was doing their homework at the queryTime.
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	startTime.length == endTime.length
27 * 	1 <= startTime.length <= 100
28 * 	1 <= startTime[i] <= endTime[i] <= 1000
29 * 	1 <= queryTime <= 1000
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time/
35// discuss: https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn busy_student(start_time: Vec<i32>, end_time: Vec<i32>, query_time: i32) -> i32 {
41        0
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_1450() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.