| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- attribute
- kaggle
- 운영체제
- Python
- shiba
- 715. Range Module
- 시바견
- Substring with Concatenation of All Words
- 파이썬
- Protocol
- 43. Multiply Strings
- Class
- Decorator
- LeetCode
- DWG
- 밴픽
- iterator
- concurrency
- 프로그래머스
- Regular Expression
- 315. Count of Smaller Numbers After Self
- t1
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- Generator
- data science
- 컴퓨터의 구조
- Python Code
- Python Implementation
- 30. Substring with Concatenation of All Words
Archives
- Today
- Total
Scribbling
LeetCode: 67. Add Binary 본문
class Solution:
def addBinary(self, a: str, b: str) -> str:
if len(b) > len(a):
a, b = b, a
b = '0'*(len(a)-len(b)) + b
ret = ''
carry = 0
for i in range(len(a)-1, -1, -1):
temp = int(a[i]) + int(b[i]) + carry
ret += str(temp%2)
carry = temp//2
if carry:
ret += str(1)
return ret[::-1]
'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 71. Simplify Path (0) | 2021.09.26 |
|---|---|
| LeetCode: 69. Sqrt(x) (0) | 2021.09.26 |
| LeetCode: 64. Minimum Path Sum (0) | 2021.09.24 |
| LeetCode: 63. Unique Paths II (0) | 2021.09.24 |
| LeetCode: 62. Unique Paths (0) | 2021.09.24 |