Mid/SeniorMath

Angle Between Hands of a Clock

Given two numbers, hour and minutes, return the smaller angle, in degrees, formed between the hour hand and the minute hand.

Answers within 10^-5 of the actual value will be accepted as correct.

Example 1
Inputhour = 12, minutes = 30
Output165
At 12:30, the smaller angle between the hour hand and minute hand is 165 degrees.
Example 2
Inputhour = 3, minutes = 30
Output75
At 3:30, the smaller angle between the hour hand and minute hand is 75 degrees.

Constraints

  • 1 <= hour <= 12
  • 0 <= minutes <= 59

Asked at 7 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate