leetcode:可以形成最大正方形的矩形数目

hoohack

关注

阅读 62

2022-02-04

在这里插入图片描述

class Solution:
    def countGoodRectangles(self, rectangles: List[List[int]]) -> int:
        maxLen = 0
        for rectangle in rectangles:
            maxLen = max(maxLen, min(rectangle[0], rectangle[1]))
        
        ans = 0
        for rectangle in rectangles:
            if maxLen <= rectangle[0] and maxLen <= rectangle[1]:
                ans += 1
        
        return ans

初四快乐!

相关推荐

精彩评论(0)

0 0 举报