Optimized
Intuition\n Describe your first thoughts on how to solve this problem. \nObvious solution of Brute Force is available.\n\nRemember - \nConstraints:\n\n1 <= n, m
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nObvious solution of Brute Force is available.\n\nRemember - \nConstraints:\n\n1 <= n, m <= 50\n1 <= nums1[i], nums2[j] <= 50\n1 <= k <= 50\n\nBruteforce max iters = 50 x 50 = 2500\n\n# Approach\nAdding an extra check that will be executed at max m = 50 times\nEvery time the check fails it skips inner loop which itself can be a max of n = 50 iterations.\nLets say this check fails for 5% cases we should have upto \n\n+ 50 iter - 0.05 x 50 x 50 iters = 75 iter advantage on the worst case \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n) x O(m)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def numberOfPairs(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        ans=0\n        for i in nums1:\n            if i%k==0:\n                for j in nums2:                    \n                    if i%(k*j)==0:\n                        ans+=1\n        return ans\n            \n```
['Python3']