4 lines Java solution


  • 0
    M
    
    public class Solution {
        public String addBinary(String a, String b) {
            BigInteger i = new BigInteger(a,2);
            BigInteger j = new BigInteger(b,2);
            BigInteger sum = i.add(j);
            return sum.toString(2);
        }
    }

Log in to reply
 

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