1843. Number Of Rectangles That Can Form The Largest Square
My accepted Python solution to LeetCode problem 1843, Number Of Rectangles That Can Form The Largest Square, running in 160ms.
- Difficulty: Easy
- Python
- Runtime 160ms
- Memory 18MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 160ms, memory 18MB, accepted 2025-12-31.
class Solution:
def countGoodRectangles(self, rectangles: List[List[int]]) -> int:
max_squares = [min(l, w) for l, w in rectangles]
max_len = max(max_squares)
return sum(1 for sq in max_squares if sq == max_len)