标签:bsp return leetcode lse radius als info self 矩形
题目描述:
class Solution: def checkOverlap(self, radius: int, x_center: int, y_center: int, x1: int, y1: int, x2: int, y2: int) -> bool: a = max(0, x1 - x_center, x_center - x2) ** 2 b = max(0, y1 - y_center, y_center - y2) ** 2 c = radius ** 2 return a + b <= c
另
class Solution: def checkOverlap(self, radius: int, x_center: int, y_center: int, x1: int, y1: int, x2: int, y2: int) -> bool: for x in (x1, x2): for y in (y1, y2): if dist((x_center, y_center), (x, y)) <= radius: return True if x1 <= x_center <= x2 and y1 - radius <= y_center <= y2 + radius: return True if x1 - radius <= x_center <= x2 + radius and y1 <= y_center <= y2: return True return False
标签:bsp return leetcode lse radius als info self 矩形
原文地址:https://www.cnblogs.com/oldby/p/12636086.html