Code RoomFactorial digit count
MediumPrep Room Coding #1402

Factorial digit count

CodingAlgorithms & data structuresMid–Senior~20 min

Return the number of decimal digits in n! (n factorial) for n up to about 10^5, without materializing the huge factorial. The number of digits of a positive integer x is floor(log10(x)) + 1, and log10(n!) = sum of log10(k) for k from 1 to n. Accumulate that sum in floating point and return floor(sum) + 1. By convention, 0! = 1! = 1 has 1 digit. Return 0 for n < 0.

Implement
factorial_digit_count(n: int) → int
Examples
in[10]out7
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 20 min
InputExpectedGot
[10]7not run yetsample