본문 바로가기
Problem Solving/LeetCode

[LeetCode] 836. Rectangle Overlap - Java

by graycode 2026. 10. 24.

• 문제 링크

 

Rectangle Overlap - LeetCode

Can you solve this real interview question? Rectangle Overlap - 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

leetcode.com

 

• 풀이 코드

public class Solution {

    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
        return !(rec1[2] <= rec2[0] || rec1[0] >= rec2[2] || rec1[3] <= rec2[1] || rec1[1] >= rec2[3]);
    }

}

댓글