This is a verified interview question from Visa. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Requests in the Previous 10 Minutes - Visa Online Assessment IIT BHU" covers key patterns like Arrays.
"Given a **sorted array `timestamp`** representing the timestamps of incoming requests, return an array where the `i-th` element represents the **number of requests received in the previous 10 minutes, including the current request**. For every request at time `timestamp[i]`, count all requests whose timestamps lie within the 10-minute window ending at `timestamp[i]`. ### Input * An integer `n` representing the number of requests. * A sorted integer array `timestamp` of size `n`, where `timestamp[i]` represents the timestamp of the `i-th` request. ### Output Return an integer array `ans` of size `n`, where: `ans[i] = number of requests with timestamp >= timestamp[i] - 10 and <= timestamp[i]` ### Example **Input:** ```text timestamp = [1, 2, 3, 11, 12, 13, 20] ``` **Output:** ```text [1, 2, 3, 2, 2, 3, 1] ``` ### Explanation For `timestamp[i] = 13`, the previous 10-minute window is: ```text [3, 13] ``` Requests occurred at: ```text 3, 11, 12, 13 ``` So the answer is `4`. > **Note:** The exact boundary interpretation should be confirmed from the original Visa statement. If "previous 10 minutes" means strictly more than `t-10`, use `(t-10, t]`; if inclusive, use `[t-10, t]`."
Join thousands of developers practicing for Visa.