Edabit Java Rectangle in Circle, Medium difficulty
- Justin Mah
- Mar 29, 2021
- 1 min read
edabit question: https://edabit.com/challenge/XFhvhZhf...
I solved this question using math.sqrt to find the diameter of the rectangle and compare it to the diameter of the circle




public class Challenge {
public static boolean rectangleInCircle(int w, int h, int radius) {
double rectangleDiameter = Math.sqrt((w * w) + (h * h));
double diameter = 2 * radius;
return rectangleDiameter <= diameter;
}
}
Comments