Question
Given an integer n, return the number of trailing zeroes in .
Note: Your solution should be in logarithmic time complexity.
Solution
Result: Accepted Time: 4 ms
Here should be some explanations.
class Solution {
public:
int trailingZeroes(int n) {
int ans = 0;
while(n)
{
n/=5;
ans +=n;
}
return ans;
}
};
Complexity Analytics
- Time Complexity:
- Space Complexity: