Java EASY Solution for Beginners [ 99.96% ] [ 1ms ]
Approach\n1. Initialize Counter:\n   - Create a variable count to store the number of valid pairs.\n\n2. Outer Loop:\n   - Iterate through each element i in num
# Approach\n1. **Initialize Counter**:\n   - Create a variable `count` to store the number of valid pairs.\n\n2. **Outer Loop**:\n   - Iterate through each element `i` in `nums1`.\n\n3. **Inner Loop**:\n   - For each element `i` in `nums1`, iterate through each element `j` in `nums2`.\n\n4. **Check Condition**:\n   - Check if `nums1[i] % (nums2[j] * k) == 0`.\n\n5. **Update Counter**:\n   - If the condition is true, increment `count`.\n\n6. **Return Result**:\n   - Return the value of `count`.\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int numberOfPairs(int[] nums1, int[] nums2, int k) {\n        int count=0;\n        for(int i=0; i<nums1.length; i++){\n            for(int j=0; j<nums2.length; j++){\n                if(nums1[i]%(nums2[j]*k) == 0) count++;\n            }\n        }\n        return count;\n    }\n}\n```\n\n![193730892e8675ebafc11519f6174bee5c4a5ab0.jpeg](https://assets.leetcode.com/users/images/57894527-775c-4b3b-a365-edb1190c8562_1718520198.6228821.jpeg)\n
['Java']