Given two binary strings, return their sum (also a binary string).
For example,
a ="11"
b = "1"
Return "100"
. 博主对于自己那冗长的代码真是累感不爱了~连注释都不用标了,特别清晰明了,捂脸逃走~只能安慰自己起码跑过了。。。
public class Solution { public String addBinary(String a, String b) { String n1=new StringBuilder(a).reverse().toString(); String n2=new StringBuilder(b).reverse().toString(); StringBuilder sb= new StringBuilder(); int l=Math.min(a.length(),b.length()); int carry=0; int digit=0; for(int i=0;ib.length()){ for(int i=l;i