With Explanation Comments: Time: 13 ms (76.88%), Space: 11.9 MB (30.30%)
Like it? ->Upvote please!\n\n\'\'\'\nclass Solution {\npublic:\n    int countPairs(vector& nums, int k) {\n        \n        //initialize a counter variable\n  
**Like it? ->Upvote please!**\n\n\'\'\'\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums, int k) {\n        \n        //initialize a counter variable\n        int counter=0;\n        \n        //loop over the whole array elements\n        for(int i=0;i<nums.size()-1;i++){\n            //loop again over them to compare\n            for(int j=i+1;j<nums.size();j++){\n                //condition 1: j is always smaller than i\n                if(i>=j)\n                    continue;\n                \n                //condition 2: the two numbers are equal\n                if(nums[i]==nums[j])\n                    //condition 3: (i*j) is divisible by the given number k\n                    if ((i*j)%k==0)\n                        //all conditions are passed-> add the counter by one\n                        counter++;\n            }\n        }\n        \n        //return the counter value\n        return counter;\n    }\n};\n\'\'\'\n\n**Like it? ->Upvote please!**
['Array', 'C', 'Counting', 'C++']