[Java] O(n) time, O(1) space
\nclass Solution {\n    public int countGoodRectangles(int[][] rectangles) {\n        int count=0, maxLen=Math.min(rectangles[0][0],rectangles[0][1]);\n        
```\nclass Solution {\n    public int countGoodRectangles(int[][] rectangles) {\n        int count=0, maxLen=Math.min(rectangles[0][0],rectangles[0][1]);\n        for(int i=0;i<rectangles.length;i++){\n            int curLen = Math.min(rectangles[i][0],rectangles[i][1]);\n            if(curLen==maxLen) count++;\n            else if(curLen>maxLen) {\n                count=1;\n                maxLen=curLen;\n            }\n        }\n        return count;\n    }\n}\n```
[]