1725. Number Of Rectangles That Can Form The Largest Square Easy

@problem@discussion
#Array



1/**
2 * [1725] Number Of Rectangles That Can Form The Largest Square
3 *
4 * You are given an array rectangles where rectangles[i] = [li, wi] represents the i^th rectangle of length li and width wi.
5 * 
6 * You can cut the i^th rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length of at most 4.
7 * 
8 * Let maxLen be the side length of the largest square you can obtain from any of the given rectangles.
9 * 
10 * Return the number of rectangles that can make a square with a side length of maxLen.
11 * 
12 *  
13 * Example 1:
14 * 
15 * 
16 * Input: rectangles = [[5,8],[3,9],[5,12],[16,5]]
17 * Output: 3
18 * Explanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5].
19 * The largest possible square is of length 5, and you can get it out of 3 rectangles.
20 * 
21 * 
22 * Example 2:
23 * 
24 * 
25 * Input: rectangles = [[2,3],[3,7],[4,3],[3,7]]
26 * Output: 3
27 * 
28 * 
29 *  
30 * Constraints:
31 * 
32 * 
33 * 	1 <= rectangles.length <= 1000
34 * 	rectangles[i].length == 2
35 * 	1 <= li, wi <= 10^9
36 * 	li != wi
37 * 
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/
42// discuss: https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47    pub fn count_good_rectangles(rectangles: Vec<Vec<i32>>) -> i32 {
48        0
49    }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn test_1725() {
60    }
61}
62


Back
© 2025 bowen.ge All Rights Reserved.