Facebook
From Rahul, 2 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 73
  1. class Solution {
  2. public:
  3.     int numPairsDivisibleBy60(vector<int>& time) {
  4.         int ans = 0;
  5.         map<int,int> mp;
  6.         for(auto x:time){
  7.             int mod = x%60;
  8.             if(mp.count((60 - mod)%60) > 0){
  9.                 ans += mp[(60 -mod)%60];
  10.             }
  11.             mp[mod]++;
  12.         }
  13.         return ans;
  14.     }
  15. };