Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 568 Bytes

1725.md

File metadata and controls

22 lines (20 loc) · 568 Bytes

1725. Number Of Rectangles That Can Form The Largest Square

Solution 1 (time O(n), space O(1))

class Solution(object):
    def countGoodRectangles(self, rectangles):
        """
        :type rectangles: List[List[int]]
        :rtype: int
        """
        ans = 0
        ans_len = 0
        for x, y in rectangles:
            cur_len = min(x, y)
            if cur_len > ans_len:
                ans_len = cur_len
                ans = 1
            elif cur_len == ans_len:
                ans += 1
        return ans