Count Equal and Divisible Pairs in an Array

PHOTO EMBED

Thu Oct 20 2022 13:07:05 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    int countPairs(vector<int>& nums, int k) {
        int n=nums.size();
        int c=0;
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                int p=i*j;
                if(nums[i]==nums[j]&&p%k==0) c++;
            }
        }
        return c;
    }
};
content_copyCOPY

https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/