package leetcode;

/**
 * https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/
 */
public class Problem1725 {
    public int countGoodRectangles(int[][] rectangles) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1725 prob = new Problem1725();
        System.out.println(prob.countGoodRectangles(new int[][]{
            {5,8},{3,9},{5,12},{16,5}
        })); // 3
        System.out.println(prob.countGoodRectangles(new int[][]{
            {2,3},{3,7},{4,3},{3,7}
        })); // 3
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -253,371 +253,353 @@
     
-// 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        Problem1725 prob = new Problem1725();%0A        System.out.println(prob.countGoodRectangles(new int%5B%5D%5B%5D%7B%0A            %7B5,8%7D,%7B3,9%7D,%7B5,12%7D,%7B16,5%7D%0A        %7D)); // 3%0A        System.out.println(prob.countGoodRectangles(new int%5B%5D%5B%5D%7B%0A            %7B2,3%7D,%7B3,7%7D,%7B4,3%7D,%7B3,7%7D%0A        %7D)); // 3
+int max = 0;%0A        for (int%5B%5D rectangle : rectangles) %7B%0A            int val = Math.max(answer, Math.min(rectangle%5B0%5D, rectangle%5B1%5D));%0A            map.put(val, map.getOrDefault(val, 0) + 1);%0A            max = Math.max(max, val);%0A        %7D%0A        return map.get(max);
 %0A   

Solve problem 1725