Language C++ ✓ Autocomplete Ready O ★ 1 > #include . 9 10 /* 11 * Complete the solve function below. 12 13 * The function is expected to return an INTEGER_ARRAY. 14 + The function accepts following parameters 15 1. INTEGER X 16 2. INTEGER ARRAY arr 17 3. INTEGER ARRAY query_values 18 19 20 vector solve(int x, vector int> arr, vector query_values) 21 22 } 23 24 > int main() ★ .
Answers
Answered by
0
Answer:
Given n ranges of the form L and R, the task is to find the maximum occurred integer in all the ranges. If more than one such integer exists, print the smallest one.
0 <= Li, Ri < 1000000.
Examples :
Input : L1 = 1 R1 = 15
L2 = 4 R2 = 8
L3 = 3 R3 = 5
L4 = 1 R4 = 4
Output : 4
Input : L1 = 1 R1 = 15
L2 = 5 R2 = 8
L3 = 9 R3 = 12
L4 = 13 R4 = 20
L5 = 21 R5 = 30
Output : 5
Numbers having maximum occurrence i.e 2 are 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15. The smallest number
among all are 5
Explanation:
Similar questions