[leetcode] Add Binary
Add Binary Given two binary strings, return their sum (also a binary string). For example, a = “11” b = “1” Return “100”. 二进制加法,注意进位。和字符串访问时的末尾对齐。 class Solution { public: string addBinary(string a, string b) { if(a.empty()) return b; else if(b.empty()) return a; int carry = 0; string sum; int i = […]