Count Equal Pairs with Index Product Divisible by k
IntuitionWe're given an array nums and an integer k. We need to count pairs of indices (i, j) such that:

i < j


nums[i] == nums[j]


(i * j) % k == 0

The bru
# Intuition
We're given an array nums and an integer k. We need to count pairs of indices (i, j) such that:

- i < j

- nums[i] == nums[j]

- (i * j) % k == 0

The brute-force approach iterates over all pairs and directly checks the three conditions.



# Approach
1. Use two nested loops to go over all index pairs (i, j) with i < j.

2. For each pair, check:

- If the values are equal.

- If the product of the indices (i * j) is divisible by k.

3. Count the number of such valid pairs.

This is straightforward and works fine for small input sizes.



# Complexity
- Time complexity:

O(n²) — due to the double loop over all index pairs.

- Space complexity:

O(1) — only uses a counter variable, no extra data structures.

# Code
```cpp []
class Solution {
public:
    int countPairs(vector<int>& nums, int k) {
        int counter = 0;
        for(int i = 0; i < nums.size() -1; i++)
        {
            for(int j = i +1; j < nums.size(); j++)
            {
                if(nums[i] == nums[j])
                {
                    if(i * j % k == 0)
                        counter++;
                }
            }
        }
        return counter;
    }
};
```
['Array', 'Math', 'Counting', 'C++']