일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 파이썬
- DWG
- Decorator
- Substring with Concatenation of All Words
- t1
- 시바견
- Python Code
- attribute
- Python Implementation
- Regular Expression
- Python
- 밴픽
- Protocol
- 315. Count of Smaller Numbers After Self
- 운영체제
- data science
- Generator
- 30. Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- LeetCode
- Class
- 프로그래머스
- 109. Convert Sorted List to Binary Search Tree
- concurrency
- 715. Range Module
- 컴퓨터의 구조
- shiba
- 43. Multiply Strings
- kaggle
- iterator
- Today
- Total
목록43. Multiply Strings (2)
Scribbling
class Solution: def multiply(self, num1: str, num2: str) -> str: if num1 == '0' or num2 == '0': return '0' ret = [0] * (len(num1) + len(num2)) for i in range(len(num1)-1, -1, -1): carry = 0 for j in range(len(num2)-1, -1, -1): temp = ret[i+j+1] + int(num1[i]) * int(num2[j]) + carry carry = temp // 10 ret[i+j+1] = temp % 10 ret[i] = carry ret = ''.join(map(str, ret)) return ret.lstrip('0')
class Solution: def multiply(self, num1: str, num2: str) -> str: if num1 == '0' or num2 == '0': return '0' ret = [0] * (len(num1) + len(num2)) for i in range(len(num1)-1, -1, -1): carry = 0 for j in range(len(num2)-1, -1, -1): temp = ret[i+j+1] + int(num1[i]) * int(num2[j]) + carry carry = temp // 10 ret[i+j+1] = temp % 10 ret[i] = carry ret = ''.join(map(str, ret)) return ret.lstrip('0')