4-line Java solution using BigInteger


  • 3
    C
    public String addBinary(String a, String b) {
        BigInteger aint = new BigInteger(a,2);
        BigInteger bint = new BigInteger(b,2);
        return aint.add(bint).toString(2);
    }

Log in to reply
 

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