#1401
Circle and Rectangle Overlapping
specialist · 890 · lc medium +31 · verified · 49.9% accepted · 403 likes · top 37%
Description
You are given a circle defined by (radius, xCenter, yCenter) and an axis-aligned rectangle with bottom-left corner (x1, y1) and top-right corner (x2, y2). Return true if the circle and rectangle share at least one point, false otherwise.
Example 1:
Input: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
Output: true
Explanation: Circle and rectangle share the point (1,0).
Example 2:
Input: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
Output: false
Example 3:
Input: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
Output: true
Code
1
2
3