일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 밴픽
- 43. Multiply Strings
- shiba
- 파이썬
- Protocol
- kaggle
- Regular Expression
- Class
- 프로그래머스
- DWG
- Python
- 운영체제
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- LeetCode
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- attribute
- Python Implementation
- 시바견
- data science
- 컴퓨터의 구조
- Generator
- Python Code
- iterator
- 30. Substring with Concatenation of All Words
- concurrency
- 315. Count of Smaller Numbers After Self
- t1
- 715. Range Module
Archives
- Today
- Total
목록172. Factorial Trailing Zeroes (1)
Scribbling
LeetCode: 172. Factorial Trailing Zeroes
알고리즘 문제라고 하기도 애매한 것 같다. n! 결과값에서 맨 뒤에 놓이는 0의 갯수를 찾는 문제이다. 맨 뒤의 0의 갯수는 n!으로 만들 수 있는 10의 갯수와 동일한데, 10은 2*5이므로, 2*5가 몇 번 발생하는지 확인하면 된다. 2*5의 횟수는 다시 5의 횟수로 결정된다. (2는 흔하니까) class Solution: def trailingZeroes(self, n: int) -> int: ret = 0 x = 5 while n >= x: ret += n // x x *= 5 return ret
Computer Science/Coding Test
2021. 12. 4. 16:12