Find the Smaller Angle Between Clock Hands

Last updated: August 14, 2026

Quick Overview

This question asks the candidate to calculate the smaller angle between the hour and minute hands of a clock at a given time.

Amazon
Coding & Algorithms
Software Engineer
Amazon
August 14, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

1

0

19 solved


This question asks the candidate to calculate the smaller angle between the hour and minute hands of a clock at a given time.

In a technical screen at Amazon, this question is often posed to evaluate a candidate's problem-solving skills and their ability to implement algorithms effectively. The interviewer is looking for a clear understanding of the mathematical concepts involved and the ability to translate that into efficient code. This question also tests the candidate's ability to communicate their thought process and adapt their approach based on feedback.

What the Interviewer Expects
  • Clearly explain the mathematical principles behind clock angles.
  • Provide a well-structured algorithm to compute the angle.
  • Implement the solution in a programming language, typically Python.
  • Discuss the time and space complexity of the solution.
  • Handle edge cases such as 12:00 or 6:30.
Key Topics to Cover
Mathematical concepts
Algorithm design
Time complexity
Edge cases
Python implementation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you optimize your solution further?
  • Can you explain the logic behind your angle calculation?
  • What would you do if the input was given in a different format?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Approach

To find the smaller angle between the clock hands, we first need to understand how the positions of the hour and minute hands are determined based on the time provided. The hour hand moves 30 degrees ...

Algorithm
  1. Convert the hour and minute into their respective angles:
    • Hour angle = (Hour % 12) * 30 + (Minute / 60) * 30
    • Minute angle = Minute * 6
  2. Calculate the absolute difference between the two...

Submit Your Answer
Markdown supported