O(1) C++ solution. Beats 100% submissions. 
ApproachRefer to the given visualisation. (Credits to the original creator.)Complexity

Time complexity:
O(1)


Space complexity:
O(1)

Code
![image.png](https://assets.leetcode.com/users/images/7e066c30-a75c-496f-b551-3308d900d83d_1743093614.7360358.png)


# Approach

Refer to the given visualisation. (Credits to the original creator.)

![image.png](https://assets.leetcode.com/users/images/a5d7b731-1e07-44c1-a938-67e2477bc3fd_1743093520.3301105.png)



# Complexity
- Time complexity:
O(1)

- Space complexity:
O(1)

# Code
```cpp []
class Solution {
public:
    bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
        if(rec1[0] < rec2[2])
        {
            if(rec1[2] > rec2[0])
            {
                if((rec1[1] < rec2[3]) && rec1[3] > rec2[1])
                    return true;
            }

            else
                return false;
        }

        return false;
    }
};
```
['Geometry', 'C++']