一:解题思路
Time:O(log_5(n)),Space:O(1)
二:完整代码示例 (C++版和Java版)
C++:
class Solution { public: int trailingZeroes(int n) { int count = 0; while (n > 0) { n /= 5; count += n; } return count; } };
Java:
class Solution { public int trailingZeroes(int n) { int count=0; while(n>0) { n/=5; count+=n; } return count; } }
原文地址:https://www.cnblogs.com/repinkply/p/12627097.html
时间: 2024-11-06 23:47:30