Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long countTriplets(vector<long> arr, long r) {
- map<long,long> rm;
- map<long,long> lm;
- long m = arr.size();
- long i = 0;
- long sum=0;
- for(i=0;i<=m;i++)
- {
- rm[arr[i]]++;
- }
- for(i=0;i<=m;i++)
- {
- rm[arr[i]]--;
- sum += (lm[arr[i]/r]) * (rm[arr[i]*r]);
- lm[arr[i]]++;
- }
- return sum;
- }
Add Comment
Please, Sign In to add comment