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/
No comments:
Post a Comment