public class Solution {
public int CountGoodRectangles(int[][] rectangles) {
var minCounts = new Dictionary<int, int>();
foreach (var r in rectangles) {
var min = Math.Min(r[0], r[1]);
minCounts[min] =
(minCounts.TryGetValue(min, out int value) ? value : 0) + 1;
}
return minCounts[minCounts.Keys.Max()];
}
}
Source: https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Thursday, March 4, 2021
Leetcode Everyday: 1725. Number Of Rectangles That Can Form The Largest Square. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment