Three Lines Solution in Java

  • -4
    public static String addBinary(String a, String b) {
    	java.math.BigInteger aa = new java.math.BigInteger(a, 2);
    	java.math.BigInteger bb = new java.math.BigInteger(b, 2);
    	return aa.add(bb).toString(2);

    I don't know whether this solution is OK,but it seems really simple .

  • 0

    I think your solution misses the spirit of the question..... What if the numbers are bigger than a BigInteger?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.