Reported December 2025
Scale AImath

Clock Hand Angle with Subsecond Precision

Reported by candidates from Scale AI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Scale AI OA. Under 2s to a working solution.
Founder's read

Scale AI reported this one in December 2025, and the opening angle is the data structure: there isn't one. No array, no map, just a string you parse and some arithmetic. It looks like a warm-up, and that's the trap. The clock-angle problem is a math question wearing a parsing costume, and the subsecond precision is where people lose points. If you've got an OA coming, know the two formulas cold and parse carefully. StealthCoder sits invisibly on your screen as a safety net if your mind goes blank on the constants mid-assessment.

The problem

Given a valid time on a 12-hour analog clock, return the smaller angle in degrees between the hour hand and the minute hand.
The input time uses one of these forms:
HH:MM
HH:MM:SS
HH:MM:SS.mmm
Both hands move continuously. Seconds and milliseconds therefore affect both the minute-hand and hour-hand positions.

Function
smallerClockAngle(time: String) → double

Examples
Example 1
time = "03:45"
return = 157.5
At 03:45, the minute hand is at 270 degrees and the hour hand is at 112.5 degrees. Their smaller separation is 157.5 degrees.
Example 2
time = "12:00:30"
return = 2.75
After 30 seconds, the minute hand has moved 3 degrees and the hour hand has moved 0.25 degrees, so the smaller angle is 2.75 degrees.
Example 3
time = "06:00:00.500"
return = 179.9541666667
Half a second after 06:00, both hands have moved continuously. Their smaller separation is approximately 179.9541666667 degrees.

Constraints
time is a valid zero-padded 12-hour clock time in one of the three documented formats.
01 <= HH <= 12, 00 <= MM, SS <= 59, and 000 <= mmm <= 999.
Missing seconds or milliseconds are treated as 0.
Return a value in the closed range [0, 180]. Answers within 10^-6 of the correct value are accepted.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is converting everything to total seconds, including the milliseconds as a fraction. Let s = (HH mod 12)*3600 + MM*60 + SS + mmm/1000. The hour hand moves 360 degrees per 43200 seconds, so hour = s/120. The minute hand moves 360 per 3600 seconds, so minute = (s mod 3600)/10. Take the absolute difference d, then return min(d, 360 - d). The common pitfalls: forgetting 12 should map to 0, ignoring seconds in the hour hand, and splitting the string wrong when seconds or milliseconds are missing. Default missing parts to 0. Check Example 3 by hand, it should give about 179.9541666667. Floating point is fine since tolerance is 1e-6. If you blank on the formulas during the live OA, StealthCoder is the hedge that hands you the working version.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Clock Hand Angle with Subsecond Precision cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as angle between hands of a clock. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Scale AI's OA.

Scale AI reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Clock Hand Angle with Subsecond Precision FAQ

What's the trick in the Scale AI clock angle problem?+

Convert the time to total seconds with milliseconds as a fraction, then derive both hand positions from that single number. Hour hand is s/120 degrees, minute hand is (s mod 3600)/10. Take the absolute difference and return the smaller of d and 360 - d.

How hard is this really?+

Easy on algorithm, medium on care. There's no data structure or complexity concern. The failures come from parsing the three formats, the 12 to 0 mapping, and forgetting that seconds move the hour hand too.

How do I parse HH:MM, HH:MM:SS, and HH:MM:SS.mmm?+

Split on ':' first. Part one is hours, part two is minutes. If a third part exists, split it on '.'. The left side is seconds and the right side is milliseconds. Default anything missing to 0, and parse milliseconds as an integer divided by 1000.

Do I need to worry about floating point precision?+

No. The accepted tolerance is 10^-6, and doubles handle this easily. Just avoid integer division by accident. Compute with doubles from the start and don't round your output early.

How do I prepare for this in 48 hours?+

Write the solution once from memory and test the three examples: 157.5, 2.75, and 179.9541666667. Then test edge cases like 12:00, 06:00, and 12:59:59.999. That covers the whole problem. Don't spend time on anything fancier.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Scale AI.

OA at Scale AI?
Invisible during screen share
Get it