package leetcode;

/**
 * https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/
 */
public class Problem1013 {
    public int numPairsDivisibleBy60(int[] time) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1013 prob = new Problem1013();
        System.out.println(prob.numPairsDivisibleBy60(new int[]{30, 20, 150, 100, 40})); // 3
        System.out.println(prob.numPairsDivisibleBy60(new int[]{60, 60, 60})); // 3
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -245,309 +245,465 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1013 prob = new Problem1013();%0A        System.out.println(prob.numPairsDivisibleBy60(new int%5B%5D%7B30, 20, 150, 100, 40%7D)); // 3%0A        System.out.println(prob.numPairsDivisibleBy60(new int%5B%5D%7B60, 60, 60%7D)); // 3
+for (int i = 0; i %3C time.length; i++) %7B%0A            int a = time%5Bi%5D %25 60;%0A            int b = (60 - a) %25 60;%0A            if (map.containsKey(b)) %7B%0A                answer += map.get(b);%0A            %7D%0A            if (!map.containsKey(a)) %7B%0A                map.put(a, 1);%0A            %7D else %7B%0A                map.put(a, map.get(a) + 1);%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1013