Preimage Size of Factorial Zeroes Function
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Let f(x) be the number of trailing zeros in x! (with 0! = 1). For example f(3) = 0 because 3! = 6, and f(11) = 2 because 11! = 39916800.
Given a non-negative integer k, return how many non-negative integers x satisfy f(x) = k.
The answer is always either 0 or 5. k can be up to 10^9, so search for x rather than computing factorials, and use 64-bit integers for the search range.
Examples
Constraints
- 0 <= k <= 10^9
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.