C++ GCD Hash Table Solution
Runtime: 408 ms, faster than 63.57% of C++ online submissions for Count Array Pairs Divisible by K.\nMemory Usage: 65 MB, less than 82.95% of C++ online submiss
Runtime: 408 ms, faster than 63.57% of C++ online submissions for Count Array Pairs Divisible by K.\nMemory Usage: 65 MB, less than 82.95% of C++ online submissions for Count Array Pairs Divisible by K.\n\n```\n\n(n * n2) % k == 0 => (GCD (n1, k) * GCD(n2,k)) % k == 0\nStore all GCD of num and k frequency in Hash Table \nand check above condition for previous GCDs and update count\n\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        \n        int size = nums.size();\n        long long count  = 0;\n        long long v;\n        \n        // store GCD frequency\n        unordered_map<int,int>track;\n\n        // loop through nums array and update count based on previous GCD values\n        for(int &num : nums)\n        {\n            int gcdVal = __gcd(num,k);\n\n            // update count based on all previous GCD frequency \n            // if current GCD * previous GCD % k == 0\n            for(auto &t : track)\n            {\n                v = (long long)gcdVal * (long long)t.first;\n                \n                if(v % k ==0)count+= t.second;\n            }\n        \n            // update current GCD frequency\n            track[gcdVal]++;\n        }\n        \n        return count;    \n    }\n};\n```
['Hash Table', 'Math', 'C']