Skip to content

Commit b0107ba

Browse files
committed
update
1 parent 21b1764 commit b0107ba

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

Python/factorial-trailing-zeroes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Time: O(logn)
2+
# Space: O(1)
3+
#
4+
# Given an integer n, return the number of trailing zeroes in n!.
5+
#
6+
# Note: Your solution should be in logarithmic time complexity.
7+
#
8+
9+
class Solution:
10+
# @return an integer
11+
def trailingZeroes(self, n):
12+
result = 0
13+
while n > 0:
14+
result += n / 5
15+
n /= 5
16+
return result
17+
18+
if __name__ == "__main__":
19+
print Solution().trailingZeroes(100)

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
LeetCode
22
========
33

4-
Up to date (2014-12-27), there are total `171` problems on [LeetCode Online Judge](https://oj.leetcode.com/).
4+
Up to date (2014-12-30), there are total `172` problems on [LeetCode Online Judge](https://oj.leetcode.com/).
55
The number of problems is increasing recently.
6-
Here is the classification of all `171` problems.
6+
Here is the classification of all `172` problems.
77
I'll keep updating for full summary and better solutions. Stay tuned for updates.
88

99
---
@@ -305,7 +305,8 @@ Problem | Solution | Time | Space | Difficul
305305
--------------- | --------------- | --------------- | --------------- | -------------- | -----
306306
[Divide Two Integers] | [divide-two-integers.py] | _O(logn)_ | _O(1)_ | Medium |
307307
[Excel Sheet Column Title] | [excel-sheet-column-title.py] | _O(logn)_ | _O(1)_ | Easy |
308-
[Excel Sheet Column Number] | [excel-sheet-column-number.py] | _O(n)_ | _O(1)_ | Easy |
308+
[Excel Sheet Column Number] | [excel-sheet-column-number.py] | _O(n)_ | _O(1)_ | Easy |
309+
[Factorial Trailing Zeroes] | [factorial-trailing-zeroes.py] | _O(logn)_ | _O(1)_ | Easy |
309310
[Fraction to Recurring Decimal] | [fraction-to-recurring-decimal.py] | _O(logn)_ | _O(1)_ | Medium |
310311
[Gray Code] | [gray-code.py] | _O(2^n)_ | _O(1)_ | Medium |
311312
[Integer to Roman] | [integer-to-roman.py] | _O(n)_ | _O(1)_ | Medium |
@@ -321,6 +322,8 @@ Problem | Solution | Time | Space | Difficul
321322
[excel-sheet-column-title.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/excel-sheet-column-title.py
322323
[Excel Sheet Column Number]:https://oj.leetcode.com/problems/excel-sheet-column-number/
323324
[excel-sheet-column-number.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/excel-sheet-column-number.py
325+
[Factorial Trailing Zeroes]:https://oj.leetcode.com/problems/factorial-trailing-zeroes/
326+
[factorial-trailing-zeroes.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/factorial-trailing-zeroes.py
324327
[Fraction to Recurring Decimal]:https://oj.leetcode.com/problems/fraction-to-recurring-decimal/
325328
[fraction-to-recurring-decimal.py]:https://github.com/kamyu104/LeetCode/blob/master/Python/fraction-to-recurring-decimal.py
326329
[Gray Code]:https://oj.leetcode.com/problems/gray-code/

0 commit comments

Comments
 (0)