1010. Pairs of Songs With Total Durations Divisible by 60 Medium
1/**
2 * [1010] Pairs of Songs With Total Durations Divisible by 60
3 *
4 * You are given a list of songs where the i^th song has a duration of time[i] seconds.
5 * Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.
6 *
7 * Example 1:
8 *
9 * Input: time = [30,20,150,100,40]
10 * Output: 3
11 * Explanation: Three pairs have a total duration divisible by 60:
12 * (time[0] = 30, time[2] = 150): total duration 180
13 * (time[1] = 20, time[3] = 100): total duration 120
14 * (time[1] = 20, time[4] = 40): total duration 60
15 *
16 * Example 2:
17 *
18 * Input: time = [60,60,60]
19 * Output: 3
20 * Explanation: All three pairs have a total duration of 120, which is divisible by 60.
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= time.length <= 6 * 10^4
26 * 1 <= time[i] <= 500
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/
32// discuss: https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn num_pairs_divisible_by60(time: Vec<i32>) -> i32 {
38 0
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_1010() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.