Question Link :
Submission Link:
Approach
- Make a visited array and mark the factors as visited int that array While traversing the whole array
- If at some point i encounter a factor that is already visited I make my ok variable false saying that the set cannot be pairwise co prime
- And then i calculate the gcd of all the numbers and if that’s equal to 1 then i say that the array is setwise coprime
- if nothing of the above satisfies then i’'ll print not coprime
Why Am I Getting wa in some TESTS ?