Microsoft Interview Question
Program ManagersTeam: Visual Studio
Country: United States
Interview Type: In-Person
It was a pretty easy problem.. but what they were looking for is how you approach a problem. The first thing I did was ask about the format of the input. If its a string you'd need to parse it and convert into integer, if its in 24hr format.. you would need to convert it to 12 hr, and other things like that... Then, I asked about the format of the output, at which point the interviewer clarified she wanted the acute angle.
Also, while solving it out on the board, you should explain each step instead of just doing it all in your head and then writing the formula. Thats what they are looking for in a PM.
difference between the minute and hour clock travel, so
(360/60) m - (360/12) h - (30/60)m
which comes to
30 * h - 5.5 * m
I think this problem needs lots of clarifying questions.
1) between which hands: hour-minute; minute-second; hour-second
2) how are we reading the input form the clock?
3) Does clock hand move contiguously or they tick?
4) Do we want to calculate the angles at each given time or we want to have program contiguously display the angles.
5) do want to store these angles?
...
Minutes Angle = (360 * m) / 60 = 6 * m where m is the minutes.
- Naveen Reddy Mandadi October 23, 2012Hour Angle = ((360 * h) / 12) + (360 * m / 12 * 60) = 30 * h + m / 2
From the above two values get the difference by subtracting the bigger value from the smaller value.
If the difference is more than 180 then 360 - diff will be the acute angle else diff itself is the acute angle.