Problem statement

https://binarysearch.com/problems/Clock-Angle/

Solution

Equal to Leetcode 1344. Angle Between Hands of a Clock, just fix hours to 0-12 range and use floor in the end.

Complexity

It is O(1) for time and space.

Code

class Solution:
    def solve(self, hour, minutes):
        if hour > 12: hour -= 12
        return floor(min(abs(30*hour-5.5*minutes),360-abs(30*hour - 5.5*minutes)))