Solution using bruteforce in JAVA
\n# Approach\n Describe your approach to solving the problem. \nThe code uses two for loops to iterate through the array. The first loop starts at 0 and goes up
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe code uses two for loops to iterate through the array. The first loop starts at 0 and goes up to n-1, where n is the length of the array. The second loop starts at i+1 and goes up to n-1. If arr[i]==arr[j] && i*j%k==0 then count++\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int countPairs(int[] arr, int k) {\n        int n = arr.length;\n        int count = 0;\n        for(int i=0; i<n;i++){\n            for(int j=i+1; j<n; j++){\n                if(arr[i]==arr[j] && i*j%k==0)\n                count++;\n            }\n        }\n        return count;\n    }\n}\n```
['Java']