AmazonOA #281
Maximum User Traffic
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & Ranges
User i is online every day from login[i] to logout[i], inclusive at both ends; on the same day, logins happen before logouts. Find how many days have an online count equal to the global maximum online count; do not return the count itself.
Input
The first line contains n, the second line contains login, and the third line contains logout. 1≤n≤100000, 0≤login[i]≤logout[i]≤100000.
Output
Output a single integer, the answer.
Example 1
Input:
3
1 2 7
3 4 7
Output:
2
Example 2
Input:
1
0
0
Output:
1
Example 3
Input:
2
1 3
1 3
Output:
2
Example notes
The answers are 2, 1 and 2 respectively. In the first example, days 2 and 3 both have two users online; in the third example, two non-adjacent days both reach the peak of 1.
Editorial
Loading solution…