Angle Between Hands of a Clock LeetCode solution in Java

1
class Solution {
2
public double angleClock(int hour, int minutes) {
3
// Position of hour hand in a circle of 0 - 59
4
double hrPos = 5 * (hour % 12);
5

6
// Adjust hour hand position according to minute hand
7
hrPos += (5 * minutes / 60.0);
8

9
double units = Math.abs(minutes - hrPos);
10

11
// Take the min of distance between minute & hour hand and hour & minute hand
12
return Math.min(units, 60 - units) * 6;
13
}
14
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0