Skip to content

Commit 79657db

Browse files
committed
feat(array): ✨1010的第二种解法
1 parent bc3ce67 commit 79657db

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

array/1010/solution2.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/
3+
*
4+
* 1010. Pairs of Songs With Total Durations Divisible by 60
5+
*
6+
* Easy
7+
*
8+
* 72ms 76.61%
9+
* 38.6mb 14.48%
10+
*/
11+
const numPairsDivisibleBy60 = time => {
12+
13+
const cache = new Map()
14+
let ans = 0
15+
for (let t of time) {
16+
ans += cache.get((60 - t % 60) % 60) || 0
17+
18+
const temp = cache.get(t % 60) || 0
19+
cache.set(t % 60, temp + 1)
20+
}
21+
22+
return ans
23+
}

0 commit comments

Comments
 (0)