문돌이 존버/프로그래밍 스터디
2021. 9. 26.
(leetcode 문제 풀이) Add Binary
Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: - 1 len(b): for _ in range(len(a) - len(b)): b = '0' + b else: for _ in range(len(b) - len(a)): a = '0' + a std_len = max(len(a), len(b)) # 맨 뒤의 원소를 먼저 비교해서 높임 여부 확인 if a[-1] == '1' and b[-1] == '1': carry =..