EFFICENT SOLUTION | HASHING
Intuition\nwe store the indexes of the elements in map and iterate through them to check the given condition\n\n# Approach\n the code maintains a map that store
# Intuition\nwe store the indexes of the elements in map and iterate through them to check the given condition\n\n# Approach\n the code maintains a map that stores the indices of each element encountered in the nums vector. It then iterates through the vector, checking each element\'s indices and calculating the product of indices for each pair. If the product is divisible by k, it increments the count. Finally, it returns the count as the result.\n\n# Complexity\n- Time complexity:\no(n)\n\n- Space complexity:\no(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums, int k) {\n        int n = nums.size();\n        unordered_map<int,vector<int>> m;\n        int count = 0;\n        for(int i = 0; i < n; i++) \n        {\n            if(m.find(nums[i]) != m.end()) \n            {\n                for(auto  j: m[nums[i]]) \n                    if((i * j) % k == 0)\n                        count++;\n            }\n            \n            m[nums[i]].push_back(i);\n        }\n        return count;\n    }\n};\n```
['Hash Table', 'C++']