Class Solution
java.lang.Object
g1001_1100.s1010_pairs_of_songs_with_total_durations_divisible_by_60.Solution
1010 - Pairs of Songs With Total Durations Divisible by 60.<p>Medium</p>
<p>You are given a list of songs where the <code>i<sup>th</sup></code> song has a duration of <code>time[i]</code> seconds.</p>
<p>Return <em>the number of pairs of songs for which their total duration in seconds is divisible by</em> <code>60</code>. Formally, we want the number of indices <code>i</code>, <code>j</code> such that <code>i < j</code> with <code>(time[i] + time[j]) % 60 == 0</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> time = [30,20,150,100,40]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> Three pairs have a total duration divisible by 60:</p>
<p>(time[0] = 30, time[2] = 150): total duration 180</p>
<p>(time[1] = 20, time[3] = 100): total duration 120</p>
<p>(time[1] = 20, time[4] = 40): total duration 60</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> time = [60,60,60]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> All three pairs have a total duration of 120, which is divisible by 60.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= time.length <= 6 * 10<sup>4</sup></code></li>
<li><code>1 <= time[i] <= 500</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numPairsDivisibleBy60
public int numPairsDivisibleBy60(int[] time)
-