We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
To me this question boils down to finding if there exists (at least) one mutually-prime pair in the given list, which involves checking gcd for (up to) all possible pairs. How can one accomplish this in time faster than O(N^2)?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and GCD
You are viewing a single comment's thread. Return to all comments →
To me this question boils down to finding if there exists (at least) one mutually-prime pair in the given list, which involves checking gcd for (up to) all possible pairs. How can one accomplish this in time faster than O(N^2)?