728x90 Add Binary1 [LeetCode] 67. 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 = 0) { let sum = carry; if (i >= 0) sum += parseInt(a[i--]); if (j >= 0) sum += parseInt(b[j--]); // sum이 2보다 작으면 sum을 결과에 추가하고 carry는 0 // sum이 2라면 0을 결과에 추가하고 carry는 1 // sum이 3이라면 1을 결과에 추가하고 carry는 1 r.. 2024. 1. 30. 이전 1 다음 728x90