Count Song Pairs Whose Combined Duration Is a Multiple of Sixty
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
### Problem
For song durations in `time`, count index pairs i<j whose sum is divisible by60. Repeated durations still represent different songs at different indices.
```cpp
class Solution {
public:
int numPairsDivisibleBy60(vector<int>& time);
};
```
### Examples
**Example 1:**
```text
Input: time = [10,50,70,110]
Output: 4
Explanation: Each of the two duration-remainder10 songs pairs with either of the two remainder50 songs.
```
**Example 2:**
```text
Input: time = [30,30,90,5]
Output: 3
Explanation: Any two of the three remainder30 songs form a multiple-of60 sum. The duration5 song has no partner.
```
### Constraints
- `1 <= time.length <= 6*10^4`.
- `1 <= time[i] <= 500`.
### Contract considerations
Only distinct indices may pair, and input order is irrelevant to which pairs qualify.
```hint Read the boundary condition
Only each duration modulo60 matters when finding earlier partners.
```
### Boundary reminders
Only distinct indices may pair, and input order is irrelevant to which pairs qualify.
Overview: Count Song Pairs Whose Combined Duration Is a Multiple of Sixty. For song durations in time, count index pairs i<j whose sum is divisible by60.
Count Song Pairs Whose Combined Duration Is a Multiple of Sixty
Amazon
Jun 20, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0
Problem
For song durations in time, count index pairs i<j whose sum is divisible by60. Repeated durations still represent different songs at different indices.
class Solution {
public:
int numPairsDivisibleBy60(vector<int>& time);
};
Examples
Example 1:
Input: time = [10,50,70,110]
Output: 4
Explanation: Each of the two duration-remainder10 songs pairs with either of the two remainder50 songs.
Example 2:
Input: time = [30,30,90,5]
Output: 3
Explanation: Any two of the three remainder30 songs form a multiple-of60 sum. The duration5 song has no partner.
Constraints
1 <= time.length <= 6*10^4
.
1 <= time[i] <= 500
.
Contract considerations
Only distinct indices may pair, and input order is irrelevant to which pairs qualify.
Boundary reminders
Only distinct indices may pair, and input order is irrelevant to which pairs qualify.