Tag Archives: GCD-LCM

Largest subarray with GCD one

There is an array with n elements. Find length of the largest subarray having GCD equal to 1. If no subarray with GCD 1, then print -1. Examples: Input : 1 3 5 Output : 3 Input : 2 4 6 Output :-1 A simple solution is to consider every subarray and find its GCD… Read More »