✅ Hashmap Solution Python3
Intuition\n Describe your first thoughts on how to solve this problem. \nI applied what I learned in Two Sum by using a Hashmap and mapping each value to a list
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI applied what I learned in `Two Sum` by using a Hashmap and mapping each value to a list of indexes within the given list. I knew I\'d have to check each index within that list so thats why there is a `for loop` that loops through each of the indexes within `d[n]` which is storing all the indexes for a number `n`. \n\nThis was the first time I solved a Hashmap related question with no assistance!\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n\n# Code\n```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n\n        # PYTHON3 Hashmap Approach\n\n        # default dict hashmap\n        d = defaultdict(list)\n\n        count = 0\n\n        # enumerate each number into index and value\n        for i, n in enumerate(nums):\n\n            # we check if the number is a key to our dictionary\n            if n in d:\n\n                # if it is, loop through each index that is associated\n                # to that number and check if the product of the current\n                # index and the index associated to the number is divisible\n                # by k\n                for index in d[n]:\n                    if index * i % k == 0:\n\n                        # if it is divisible, increment count\n                        count += 1\n\n            # after checking the hashmap, append the index to the key of the\n            # current number\n            d[n].append(i)\n        \n        # return the total count\n        return count\n```
['Array', 'Hash Table', 'Python3']