Pyhton3 solution using dictionary beats 99.7%
stats\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nwe have a dictionary to s
# stats\n![Screenshot 2023-08-08 at 10.04.55 PM.png](https://assets.leetcode.com/users/images/50204932-e423-445f-a363-604c06a10146_1691512534.2270777.png)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe have a dictionary to store the indices in a array by looping through the array   \n    We have function make which tries all combinations in the indices and checks if their product id dicvisible by k returning c\nif length of indices is 1 we can skip the iteration\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N*N) due to make function\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N) due to dictionary\n\n# Code\n```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        d={}\n        for i,v in enumerate(nums):\n            if v in d:\n                d[v].append(i)\n            else:\n                d|={v:[i]}\n        s=0\n        def make(a,n):\n            c=0\n            for i in range(n-1):\n                for j in range(i+1,n):\n                    if a[i]*a[j]%k==0:\n                        c+=1\n            return c\n        for i in d:\n            if len(d[i])==1:\n                continue\n            s+=make(d[i],len(d[i]))\n        return s\n```
['Array', 'Hash Table', 'Combinatorics', 'Python3']