package leetcode;

/**
 * https://leetcode.com/problems/tuple-with-same-product/
 */
public class Problem1726 {
    public int tupleSameProduct(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1726 prob = new Problem1726();
        System.out.println(prob.tupleSameProduct(new int[]{2,3,4,6})); // 8
        System.out.println(prob.tupleSameProduct(new int[]{1,2,4,5,10})); // 16
        System.out.println(prob.tupleSameProduct(new int[]{2,3,4,6,8,12})); // 40
        System.out.println(prob.tupleSameProduct(new int[]{2,3,5,7})); // 0
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -212,445 +212,628 @@
     
-// TODO%0A        return 0;%0A
+Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A  
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1726 prob = new Problem1726();%0A        System.out.println(prob.tupleSameProduct(new int%5B%5D%7B2,3,4,6%7D)); // 8%0A        System.out.println(prob.tupleSameProduct(new int%5B%5D%7B1,2,4,5,10%7D)); // 16%0A        System.out.println(prob.tupleSameProduct(new int%5B%5D%7B2,3,4,6,8,12%7D)); // 40%0A        System.out.println(prob.tupleSameProduct(new int%5B%5D%7B2,3,5,7%7D)); // 0
+  for (int j = i + 1; j %3C nums.length; j++) %7B%0A                int product = nums%5Bi%5D * nums%5Bj%5D;%0A                map.put(product, map.getOrDefault(product, 0) + 1);%0A            %7D%0A        %7D%0A        int answer = 0;%0A        for (int count : map.values()) %7B%0A            if (count %3C= 1) %7B%0A                continue;%0A            %7D%0A            int totalCount = 0;%0A            for (int i = 1; i %3C count; i++) %7B%0A                totalCount += i;%0A            %7D%0A            answer += totalCount;%0A        %7D%0A        return answer * 8;
 %0A   

Solve problem 1726