| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 109. Convert Sorted List to Binary Search Tree
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 파이썬
- 컴퓨터의 구조
- 시바견
- kaggle
- Generator
- Protocol
- 43. Multiply Strings
- Python Code
- Decorator
- 밴픽
- DWG
- 운영체제
- 30. Substring with Concatenation of All Words
- 715. Range Module
- Regular Expression
- iterator
- Python
- t1
- LeetCode
- concurrency
- data science
- Class
- 프로그래머스
- 315. Count of Smaller Numbers After Self
- shiba
- Python Implementation
- attribute
Archives
- Today
- Total
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' 카테고리의 다른 글
| LeetCode: 198. House Robber (0) | 2021.12.04 |
|---|---|
| LeetCode: 179. Largest Number (0) | 2021.12.04 |
| LeetCode: 160. Intersection of Two Linked Lists (0) | 2021.12.02 |
| LeetCode: 162. Find Peak Element (0) | 2021.12.01 |
| LeetCode: 155. Min Stack (0) | 2021.11.30 |