> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Rectangle Overlap Python Solution with Tests

> Tested Python solution for LeetCode 836 with 18 pytest cases. Generate a practice environment with lcpy.

LeetCode 836, [Easy](/catalog/easy). Topics: [Math](/catalog/topics/math), [Geometry](/catalog/topics/geometry). [View on LeetCode](https://leetcode.com/problems/rectangle-overlap/description/).

Generate this problem as a practice environment: tested reference solution, 18 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 836   # by problem number
lcpy gen -s rectangle_overlap   # by problem name
```

## Problem

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.

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.

Given two axis-aligned rectangles `rec1` and `rec2`, return `true` if they overlap, otherwise return `false`.

### Examples

```
Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
Output: true
```

```
Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
Output: false
```

```
Input: rec1 = [0,0,1,1], rec2 = [2,2,3,3]
Output: false
```

### Constraints

* `rec1.length == 4`
* `rec2.length == 4`
* `-10^9 <= rec1[i], rec2[i] <= 10^9`
* `rec1` and `rec2` represent a valid rectangle with a non-zero area.

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rectangle_overlap/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rectangle_overlap/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
class Solution:
    # Time: O(1)
    # Space: O(1)
    def is_rectangle_overlap(self, rec1: list[int], rec2: list[int]) -> bool:
        overlap_x = max(rec1[0], rec2[0]) < min(rec1[2], rec2[2])
        overlap_y = max(rec1[1], rec2[1]) < min(rec1[3], rec2[3])
        return overlap_x and overlap_y
```

## Complexity

| Time | Space |
| - | - |
| O(1) | O(1) |

## Tags


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.