0067. Add Binary
Easy | String | 28 ms (90.81%), 14.3 MB (52.55%)
Source: LeetCode - Add Binary GitHub: Solution / Performance
Given two binary strings a
and b
, return their sum as a binary string.
Use two pointers to iterate each string from the end.
Note that need to check whether the pointer's index is larger than 0 or not. Besides, check "Carry" value in each iteration and the end of the program.
Last updated