From LeetCode. Circle-rect intersection. Solve the geometry problem "Circle and Rectangle Overlapping".
Examples
Input:[1,2,3]
Output:0
Input:[2,3,4]
Output:0
Hints
Overlap iff circle center is within radius r of any point on rectangle. Key: find closest point on rectangle to circle center.
For axis-aligned rectangle [x1,x2]×[y1,y2], closest point to (cx,cy) is (clamp(cx, x1, x2), clamp(cy, y1, y2)). Compare squared distance to r².
Rectangle fully inside circle and circle fully inside rectangle both count as overlap — nearest-point method handles both. Use squared distance throughout to avoid sqrt.
Circle and Rectangle Overlapping
**From LeetCode.** Circle-rect intersection. Solve the geometry problem "Circle and Rectangle Overlapping".