From 7f0b46f5f95b327a693185478ecefe6fe60918a0 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Sat, 3 Oct 2026 22:01:23 +0900 Subject: [PATCH] Create 1401. Circle and Rectangle Overlapping.py --- ...1401. Circle and Rectangle Overlapping.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/1401. Circle and Rectangle Overlapping.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/1401. Circle and Rectangle Overlapping.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/1401. Circle and Rectangle Overlapping.py" new file mode 100644 index 00000000..98f3cf16 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/1401. Circle and Rectangle Overlapping.py" @@ -0,0 +1,22 @@ +class Solution: + def checkOverlap(self, radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool: + # rectangle + + if xCenter < x1: + closest_x = x1 + elif xCenter > x2: + closest_x = x2 + else: + closest_x = xCenter + + if yCenter < y1: + closest_y = y1 + elif yCenter > y2: + closest_y = y2 + else: + closest_y = yCenter + + dx = xCenter - closest_x + dy = yCenter - closest_y + + return dx * dx + dy * dy <= radius * radius