class Solution { public: vector<int> v; struct node{ int cnt = 0; vector<int> id; }Node[1010]; int numPairsDivisibleBy60(vector<int>& time) { for(int i = 60; i <= 1000; i += 60) v.push_back(i); int length = time.size(); int len = v.size(); for(int i = 0; i < length; i++) { Node[time[i]].cnt++; Node[time[i]].id.push_back(i); } int ans = 0; for(int i = 0; i < length; i++) { for(int j = 0; j < len; j++) { if(v[j] == time[i]) continue; else if(v[j] < time[i] || Node[v[j] - time[i]].cnt == 0) continue; else { int m = v[j] - time[i]; int len2 = Node[m].id.size(); for(int k = 0; k < len2; k++) if(Node[m].id[k] > i) ans++; } } } return ans; } };