Count Array Pairs Divisible by K
HardLeetCodeNumber Theory
Approach hintTry it first, then revealHide
Divisibility by k depends only on gcd(nums[i], k). Because k has few divisors, count how often each gcd value occurs and test pairs of values rather than pairs of indices.