75-days-dsa-challenge

Ninja technique🥷 to ACE DSA Interviews.

View the Project on GitHub

1010. Pairs of Songs With Total Durations Divisible by 60 (Medium)

Brute force (TLE)

Hashing Solution

Code

class Solution {
public:
    int numPairsDivisibleBy60(vector<int>& time)
    {
        vector<int> mp(60);
        int n = time.size(), ans = 0;
        for (int i = 0; i < n; i++) {
            int rem = time[i] % 60;
            ans += mp[(60 - rem) % 60];
            mp[rem]++;
        }
        return ans;
    }
};