🔢 Count Valid Pairs
IntuitionThe problem requires us to find the number of valid pairs (i, j) such that:
nums1[i]mod  (nums2[j]×k)==0
nums1[i]mod(nums2[j]×k)==0My first thought was
# Intuition
The problem requires us to find the number of valid pairs (i, j) such that:
nums1[i]mod  (nums2[j]×k)==0
nums1[i]mod(nums2[j]×k)==0

My first thought was to use a brute force approach: iterate through all possible (i, j) pairs and check the condition.

# Approach
1. Initialize count = 0 to store the number of valid pairs.

2. Use nested loops to iterate through all pairs (i, j):

    ● Outer loop: Traverse nums1.

    ● Inner loop: Traverse nums2.

    ● Check if nums1[i] % (nums2[j] * k) == 0.

    ● If true, increment count and optionally log the pair.

3. Return the total count of valid pairs.

# Complexity
● Time Complexity:

    ● O(n⋅m)O(n⋅m), where nn is the length of nums1 and mm is the length of nums2.

    ● This is because we iterate over all pairs (i, j).

● Space Complexity:

    ● O(1)O(1), as we use only a single count variable.

# Code
```javascript []
/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number} k
 * @return {number}
 */
var numberOfPairs = function(nums1, nums2, k) {
    let count=0
    for(let i=0;i<nums1.length;i++){
        for(let j=0;j<nums2.length;j++){

            if(nums1[i]%(nums2[j]*k)==0){
                count++
                console.log([i,j])
            }

        }
    }
    return count
};
```

✅ Explanation with Example

Input:

nums1 = [10, 15, 20], nums2 = [2, 5], k = 2

Steps:

    Pair checks:

        ● 10 % (5 * 2) == 10 % 10 == 0 ✅

        ● 15 % (2 * 2) == 15 % 4 == 3 ❌

        ● 15 % (5 * 2) == 15 % 10 == 5 ❌

        ● 20 % (2 * 2) == 20 % 4 == 0 ✅

        ● 20 % (5 * 2) == 20 % 10 == 0 ✅

Valid pairs:

    ● (10, 5)

    ● (20, 2)

    ● (20, 5)

Output:

3

🏆 Why This Solution Works

         
● Brute-force but simple – Checks all pairs directly.
● No extra space used – Only one counter variable.
● Handles all cases correctly – Works for all k values.
🔥 Status: Accepted ✅
['JavaScript']