Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-10-17_00-01-49.png
44.3 KB
#N1725 Number Of Rectangles That Can Form The Largest Square
problem link=>https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/

#solution
class Solution {
public int countGoodRectangles(int[][] rectangles) {
int max=0, count=0, side;
for(int i=0; i<rectangles.length; i++){
side=Math.min(rectangles[i][0], rectangles[i][1]);
if(side>max){
count=1;
max=side;
}else if(side==max)
count++;
}

return count;
}
}