FastPrepMaximum User Traffic
Problems/Maximum User Traffic

Maximum User Traffic

Amazon logoAmazon● EasyFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Special thanks: Nick shared this problem.

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

Examples

Example 1

login = [1, 2, 3]logout = [10, 8, 4]return = 2
Example 1 illustration

The max user traffic is 3, which occurs on 2 days: day 3 and day 4. The answer is 2.

Constraints

  • 1 ≤ n ≤ 10^5
  • 0 ≤ login[i], logout[i] ≤ 10^5
  • login[i] ≤ logout[i]

More Amazon interview questions

  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Diagonal Traversal of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026

Similar questions at other companies

  • Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Minimum Cost of Every K-Capable Model SetTikTok · OATikTok interview questions
  • Brightest Position on a StreetCapital One · OACapital One interview questions
  • Minimum Seats for One-Way Car PoolingSquadStack.ai · OA
  • Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
  • Choose ContainersIMC Trading · OAIMC Trading interview questions
  • Temporal AnomaliesInMobi · OAInMobi interview questions
  • Find Number of Ways to Split ArrayGoogle · OAGoogle interview questions
  • Minimum Operations to Make All Array Elements EqualIBM · OAIBM interview questions

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int maximumUserTraffic(int[] login, int[] logout) {
      // write your code here
    }

}
Checking account…