Search
⌘K

Leetcode 793. Preimage Size of Factorial Zeroes Function

Count how many nonnegative integers x satisfy f(x)=k, where f(x) is the number of trailing zeros in x! (i.e., the sum of floor(x/5^i)). Key insight: f is nondecreasing with jumps aligned to multiples of 5, so the preimage size can be found by binary-searching the range for k (and is either 0 or 5).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.