Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5594
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3412
Maximum occured integer
Easy Accuracy: 44.71% Submissions: 16128 Points: 2

Given n integer ranges, the task is to find the maximum occurring integer in these ranges. If more than one such integer exits, find the smallest one. The ranges are given as two arrays L[] and R[].  L[i] consists of starting point of range and R[i] consists of corresponding end point of the range.

For example consider the following ranges.
L[] = {2, 1, 3}, R[] = {5, 3, 9)
Ranges represented by above arrays are.
[2, 5] = {2, 3, 4, 5}
[1, 3] = {1, 2, 3}
[3, 9] = {3, 4, 5, 6, 7, 8, 9}
The maximum occurred integer in these ranges is 3.

Example 1:

Input:
n = 4
L[] = {1,4,3,1}
R[] = {15,8,5,4}
Output: 4
Explanation: The given ranges are [1,15]
[4, 8] [3, 5] [1, 4]. The number that
is most common or appears most times in
the ranges is 4.



Example 2:

Input:
n = 5
L[] = {1,5,9,13,21}
R[] = {15,8,12,20,30}
Output: 5
Explanation: The given ranges are
[1,15] [5, 8] [9, 12] [13, 20]
[21, 30]. The number that is most
common or appears most times in
the ranges is 5.



The task is to complete the function maxOccured() which returns the maximum occured integer in all ranges.

Expected Time Complexity: O(n).
Expected Auxiliary Space: O(maxx).
-maxx is maximum element in R[]

Constraints:
1 <= n <= 106
0 <= L[i], R[i] <= 106