LeetCode Solutions
class Solution {
public:
int numPairsDivisibleBy60(vector<int>& time) {
int ans = 0;
vector<int> count(60);
for (int t : time) {
t %= 60;
ans += count[(60 - t) % 60];
++count[t];
}
return ans;
}
};
|
class Solution {
public int numPairsDivisibleBy60(int[] time) {
int ans = 0;
int[] count = new int[60];
for (int t : time) {
t %= 60;
ans += count[(60 - t) % 60];
++count[t];
}
return ans;
}
}
|
class Solution:
def numPairsDivisibleBy60(self, time: List[int]) -> int:
ans = 0
count = [0] * 60
for t in time:
t %= 60
ans += count[(60 - t) % 60]
count[t] += 1
return ans
|