1143. Hands at an Angle
A museum clock has an hour hand and a minute hand that both move smoothly. At h:mm the hour hand points 30h + 0.5m degrees from the 12 and the minute hand points 6m degrees from the 12, with h from 0 to 11 and m from 0 to 59. The angle between the hands is the smaller of the two arcs between them, so it always lies between 0 and 180 degrees. Given the integer angle, return every time from 0:00 to 11:59, in chronological order, at which the angle between the hands is exactly angle degrees. Format each time as h:mm with no leading zero on the hour, for example "3:05" or "11:40". Return an empty array when no time qualifies.
0 <= angle <= 180 and the answer has at most 44 entries. Checking all 720 minutes with integer arithmetic is intended, in O(1) extra space beyond the output.
Example 1
- Input:
- angle = 90
- Output:
- ["3:00","9:00"]
- Explanation:
At 3:00 the hour hand is at 90 degrees and the minute hand at 0, a right angle, and the same holds at 9:00.
Example 2
- Input:
- angle = 0
- Output:
- ["0:00"]
- Explanation:
Within whole minutes the two hands point the same way only at 0:00.
Example 3
- Input:
- angle = 180
- Output:
- ["6:00"]
- Explanation:
The hands point in opposite directions at 6:00.
Constraints
0 ≤ angle ≤ 180
The answer has at most 44 entries.
How this problem is judged
- Answers
- Your answer must match exactly. Numbers compare by value, so 2 and 2.0 are equal.
Expected complexity
- Time
- O(1)
- Space
- O(1)