Problem of the day
Choose any element of the array and replace it with 'X', 1 <= 'X' <= 'M'.
Let 'N' = 3, 'M' = 5, and 'A' = [4, 3, 2].
We can replace 3 with 2.
The maximum possible GCD is 2.
First-line contains an integer 'T', which denotes the number of test cases.
For every test case:-
First-line contains two integers, 'N', and 'M'.
Second-line contains 'N' space-separated integers, elements of array 'A'.
For each test case, Return the maximum possible GCD of the array after performing the operation.
You don’t need to print anything. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' , 'M' <= 10^5
1 <= 'A[i]' <= 10^5
The Sum of 'N' overall test cases does not exceed 10^5.
Time Limit: 1 sec
2
4 5
2 5 6 12
2 4
10 15
2
5
First test case:-
We can replace 5 with 4.
The maximum possible GCD is 2.
Second test case:-
We do not need to replace any element.
The maximum possible GCD is 5.
2
5 13
3 4 2 8 7
3 12
4 14 13
1
2