All problems
1046MediumArrayHash TableCounting

Pairs of Tracks Filling Whole Minutes

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1010Pairs of Songs With Total Durations Divisible by 60

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A playlist's track lengths, in seconds, read seconds.

Return how many pairs of different positions hold two tracks whose lengths add up to a whole number of minutes, that is to a multiple of sixty seconds. A pair counts once, whichever order it is taken in.

Examples

Example 1

Input
seconds = [30, 30]
Output
1

The two lengths of thirty add to sixty, exactly one whole minute.

Example 2

Input
seconds = [59, 1, 120]
Output
1

Fifty-nine and one add to sixty. The track of a hundred and twenty already fills two whole minutes on its own, but a pair needs two tracks, and it leaves neither of the others on a whole minute.

Example 3

Input
seconds = [500, 500, 500, 500]
Output
0

Five hundred leaves twenty over a whole minute, and twenty and twenty come to forty, never sixty.

Constraints

  • 1 <= seconds.length <= 6 * 10^4
  • 1 <= seconds[i] <= 500

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def num_pairs_divisible_by60(seconds: list[int]) -> int:
Java
public int numPairsDivisibleBy60(int[] seconds)
September 7
Apply