top of page

Edabit Java Rectangle in Circle, Medium difficulty



  • 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;

}

}


resources:



9 views0 comments
Post: Blog2_Post
bottom of page