Holo code dạo
Senior Member
Hơi cồng kềnh
Java:
class Solution {
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
return ((xCenter - radius <= x2) && (xCenter + radius >= x1) && (y1 <= yCenter) && (yCenter <= y2))
|| ((yCenter - radius <= y2) && (yCenter + radius >= y1) && (x1 <= xCenter) && (xCenter <= x2))
|| Math.hypot(
Math.min(Math.abs(x1 - xCenter), Math.abs(x2 - xCenter)),
Math.min(Math.abs(y1 - yCenter), Math.abs(y2 - yCenter))) <= radius;
}
}