Magicsheet logo

Angle Between Hands of a Clock

Medium
65.3%
Updated 6/1/2025

Angle Between Hands of a Clock

What is this problem about?

The "Angle Between Hands of a Clock interview question" is a mathematical geometry problem. Given a time in hour and minutes, you need to calculate the smaller angle between the hour hand and the minute hand. This requires understanding that the hour hand doesn't stay fixed at a number—it moves slightly as the minutes pass.

Why is this asked in interviews?

Apple and Amazon use the "Angle Between Hands of a Clock coding problem" as a logic and precision test. It's a simple problem that reveals if a candidate can handle floating-point arithmetic and "Math interview pattern" logic, such as normalization (e.g., ensuring the result is the smaller angle and handling the 360-degree wrap-around).

Algorithmic pattern used

The solution relies on Degrees per Unit calculations.

  1. Minute Hand: The minute hand moves 360/60=6360 / 60 = 6 degrees per minute.
  2. Hour Hand:
    • The hour hand moves 360/12=30360 / 12 = 30 degrees per hour.
    • It also moves 30/60=0.530 / 60 = 0.5 degrees per minute.
  3. Absolute Difference: Calculate the position of each hand in degrees from the "12 o'clock" position and find the absolute difference.
  4. Minimization: If the difference is greater than 180, subtract it from 360 to get the smaller angle.

Example explanation

Time: 3:30

  • Minute hand: 30imes6=18030 imes 6 = 180 degrees.
  • Hour hand: (3imes30)+(30imes0.5)=90+15=105(3 imes 30) + (30 imes 0.5) = 90 + 15 = 105 degrees.
  • Difference: 180105=75|180 - 105| = 75 degrees. Since 75 is less than 180, the answer is 75.

Common mistakes candidates make

  • Fixed Hour Hand: Forgetting that the hour hand moves between hour marks (e.g., at 3:30, the hour hand is exactly halfway between 3 and 4, not on the 3).
  • Larger Angle: Returning the reflex angle (e.g., 285 instead of 75).
  • 12 o'clock: Failing to treat hour 12 as 0 degrees in the calculation.

Interview preparation tip

Always double-check your units. When a problem involves a circle, keep the total (360 degrees) in mind. This type of "logic teaser" is common in early-round interviews to check for basic quantitative reasoning.

Similar Questions