1344. Angle Between Hands of a Clock ¶ Time: $O(1)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9class Solution { public: double angleClock(int hour, int minutes) { const double hourHand = (hour % 12 + minutes / 60.0) * 30; const double minuteHand = minutes * 6; const double diff = abs(hourHand - minuteHand); return min(diff, 360 - diff); } }; 1 2 3 4 5 6 7 8class Solution { public double angleClock(int hour, int minutes) { final double hourHand = (hour % 12 + minutes / 60.0) * 30; final double minuteHand = minutes * 6; final double diff = Math.abs(hourHand - minuteHand); return Math.min(diff, 360 - diff); } } 1 2 3 4 5 6 7class Solution: def angleClock(self, hour: int, minutes: int) -> float: hourAngle = (hour % 12) * 30 + minutes * 0.5 minuteAngle = minutes * 6 ans = abs(hourAngle - minuteAngle) return min(ans, 360 - ans)