package leetcode;

/**
 * https://leetcode.com/problems/angle-between-hands-of-a-clock/
 */
public class Problem1344 {
    public double angleClock(int hour, int minutes) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1344 prob = new Problem1344();
        System.out.println(prob.angleClock(12, 30)); // 165
        System.out.println(prob.angleClock(3, 30)); // 75
        System.out.println(prob.angleClock(4, 50)); // 155
        System.out.println(prob.angleClock(12, 0)); // 0
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/angle-between-hands-of-a-clock/
 */
public class Problem1344 {
    public double angleClock(int hour, int minutes) {
        // Every hour is 0.5 degrees.
        double hDeg = (360 / 12) / 60.0;
        // Every minute is 6 degrees.
        double mDeg = 360 / 60.0;
        double h = hour == 12 ? 0 : hour * 5;
        double degree = (Math.abs(h - minutes) * mDeg);
        if (h < minutes) {
            degree -= minutes * hDeg;
        } else {
            degree += minutes * hDeg;
        }
        degree = Math.abs(degree);
        return Math.min(360 - degree, degree);
    }
}

Solve problem 1344