1716. 计算力扣银行的钱

题目链接:https://leetcode-cn.com/problems/number-of-rectangles-that-can-form-the-largest-square/

执行用时:196 ms, 在所有 Swift 提交中击败了100.00% 的用户
内存消耗:13.8 MB, 在所有 Swift 提交中击败了100.00% 的用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution {
func countGoodRectangles(_ rectangles: [[Int]]) -> Int {
var maxLen = 0
var count = 0
for nums in rectangles {
let l = nums[0], r = nums[1]
let k = min(l,r)
if k == maxLen {
count += 1
} else if k > maxLen {
maxLen = k
count = 1
}
}
return count
}
}

1716. 计算力扣银行的钱
https://pisces34.github.io/2022/02/04/leetcode/1725/
发布于
2022年2月4日
许可协议