836. Rectangle Overlap Easy
1/**
2 * [836] Rectangle Overlap
3 *
4 * An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.
5 * Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.
6 * Given two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.
7 *
8 * Example 1:
9 * Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
10 * Output: true
11 * Example 2:
12 * Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
13 * Output: false
14 * Example 3:
15 * Input: rec1 = [0,0,1,1], rec2 = [2,2,3,3]
16 * Output: false
17 *
18 * Constraints:
19 *
20 * rec1.length == 4
21 * rec2.length == 4
22 * -10^9 <= rec1[i], rec2[i] <= 10^9
23 * rec1 and rec2 represent a valid rectangle with a non-zero area.
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/rectangle-overlap/
29// discuss: https://leetcode.com/problems/rectangle-overlap/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn is_rectangle_overlap(rec1: Vec<i32>, rec2: Vec<i32>) -> bool {
35 false
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_836() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.