[題解]Leetcode 1401 Circle and Rectangle Overlapping 發表於 2021-01-05 分類於 Leetcode題解 閱讀次數: Valine: 文章字數: 269 所需閱讀時間 ≈ 1 分鐘 1401 Circle and Rectangle Overlapping 題目連結 12345678class Solution {public: bool checkOverlap(int radius, int x_center, int y_center, int x1, int y1, int x2, int y2) { int x = clamp(x_center,x1,x2) - x_center; int y = clamp(y_center,y1,y2) - y_center; return x*x + y*y <= radius * radius; }};