LeetCode 1344. Angle Between Hands of a Clock
Question
Given two numbers, hour
and minutes
. Return the smaller angle (in sexagesimal units) formed between the hour
and the minute
hand.
Example
1 | Input: hour = 12, minutes = 30 |
Solution
it’s Math problem. We have to calcuate the angle of each hour and each minute. And we need to calculate the hour angle which also needs to add the influence from minute, and then caculate the minute angle. At the end, we let the bigger one minus smaller one and also consider the 360 minus this.
Code
1 | //time:O(1) space:O(1) |