939. Minimum Area Rectangle Medium

@problem@discussion
#Array#Hash Table#Math#Geometry#Sorting



1/**
2 * [939] Minimum Area Rectangle
3 *
4 * You are given an array of points in the X-Y plane points where points[i] = [xi, yi].
5 * Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such rectangle, return 0.
6 *  
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2021/08/03/rec1.JPG" style="width: 500px; height: 447px;" />
9 * Input: points = [[1,1],[1,3],[3,1],[3,3],[2,2]]
10 * Output: 4
11 * 
12 * Example 2:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2021/08/03/rec2.JPG" style="width: 500px; height: 477px;" />
14 * Input: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]
15 * Output: 2
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= points.length <= 500
21 * 	points[i].length == 2
22 * 	0 <= xi, yi <= 4 * 10^4
23 * 	All the given points are unique.
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/minimum-area-rectangle/
29// discuss: https://leetcode.com/problems/minimum-area-rectangle/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn min_area_rect(points: Vec<Vec<i32>>) -> i32 {
35        0
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_939() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.