Solution for Add Binay


  • 0
    import java.math.BigInteger;
    public class Solution 
    {
        public String addBinary(String a, String b) 
        {
            BigInteger decimalValue_a = new BigInteger(a, 2);
            BigInteger decimalValue_b = new BigInteger(b, 2);
            BigInteger sum = decimalValue_a.add(decimalValue_b);
            String temp = sum.toString(2);
            return temp;
        }
    }
    

Log in to reply
 

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