Java Simple Solution 1 ms - 100% beats
Approach\nYou first have to create an array called "sides" to store the side lengths of each rectangle. Then, you iterate through the given "rectangles" array a
# Approach\nYou first have to create an array called "sides" to store the side lengths of each rectangle. Then, you iterate through the given "rectangles" array and compare the length and width of each rectangle. If the length is smaller than the width, you assign the length to the corresponding index in the "sides" array; otherwise, you assign the width.\n\nNext, you initialize two variables, "count" and "maxLen," where "count" keeps track of the count of rectangles that can form the largest square, and "maxLen" represents the maximum side length of the square.\n\nAfter populating the "sides" array, you iterate through it to find the maximum side length. For each element (num) in the "sides" array, if the current side length is greater than the current maximum (maxLen), you update the value of "maxLen" accordingly.\n\nFinally, you iterate through the "sides" array again and increment the "count" variable by 1 for each side length that matches the maximum side length (maxLen). This counts the number of rectangles that can form the largest square.\n\nIn the end, you return the value of "count" as the result, representing the number of rectangles that can make a square with a side length equal to the maximum side length obtained.\n\n---\n\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution {\n    public int countGoodRectangles(int[][] rectangles) {\n        int[] sides = new int[rectangles.length];\n        int count = 0;\n        int maxLen = 0;\n        for (int i = 0; i < rectangles.length; i++) {\n            if (rectangles[i][0] < rectangles[i][1])\n                sides[i] = rectangles[i][0];\n            else\n                sides[i] = rectangles[i][1];\n        }\n\n        for (int num : sides)\n            if(num > maxLen) maxLen = num;\n\n        for(int num : sides)\n            if(num == maxLen) count++;\n\n        return count;\n    }\n}\n```
['Array', 'Java']