Number of Students Doing Homework at a Given Time Problem

Number of Students Doing Homework at a Given Time Problem — ExecCode Easy DSA Practice

Solve the Number of Students Doing Homework at a Given Time problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given two integer arrays startTime and endTime and given an integer queryTime. Your task is to compute the required answer and return the number of students doing their homework at time queryTime. The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i]. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

Examples

Input {"startTime": [1, 2, 3], "endTime": [3, 2, 7], "queryTime": 4}; Output 1. Input {"startTime": [4], "endTime": [4], "queryTime": 4}; Output 1

Constraints

startTime.length == endTime.length 1 <= startTime.length <= 100 1 <= startTime[i] <= endTime[i] <= 1000 1 <= queryTime <= 1000

Practice Number of Students Doing Homework at a Given Time free on ExecCode. Browse DSA problems, topic map, and placement guides.