Given an array with n elements. Find length of the largest sub-array having GCD equal to 1. If no such subarray exist with GCD 1, print -1.
Input : 1 3 5 Output : 3 Input : 2 4 6 Output :-1
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer n denoting size of the array. Then in the next line are n space separated values of the array.
For each test case in a new line print the required output.
2 4 6
1 3 5
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.