Maximum User Traffic
Learn this problemProblem statement
In order to ensure a hassle-free user experience during the festive season, Amazon maintains logs of the days when its users use the Amazon Shopping app.
The user traffic of a day is said to be the maximum number of users logged into the application during that day. If a user uses the application from day login[i] to day logout[i], it increases the traffic of each day from login[i] to logout[i] (both inclusive) by 1. That is, if login[i] = 4 and logout[i] = 6, then this user increases the traffic of days 4, 5 and 6 by 1.
Given the login and logout day data of n users, find the number of days on which the user traffic is maximum.
Note that all logins take place before all logouts on a single day.
Function
maximumUserTraffic(login: int[], logout: int[]) → int
Complete the function maximumUserTraffic in the editor below.
maximumUserTraffic has the following parameter(s):
int login[n]: an array of integers with login[i] denoting the login day of i^th user.int logout[n]: an array of integers with logout[i] denoting the logout day of i^th user.Returns
int: the number of days having maximum user traffic
࣪𓏲ᡣ • . • 𐭩 Credit to Nick𓂃🖊
Examples
Example 1
login = [1, 2, 3]logout = [10, 8, 4]return = 2
Constraints
1 ≤ n ≤ 10^50 ≤ login[i], logout[i] ≤ 10^5login[i] ≤ logout[i]
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026