https://leetcode.com/problems/add-binary/
I tried to convert the string into integers using String.parseInt(stringname,2) and add the numbers, then i tried to return Integer.toBinaryString(sum).but for large strings i am getting errors.
class Solution {
public String addBinary(String a, String b) {
int n1=Integer.parseInt(a,2);
int n2=Integer.parseInt(b,2);
int n=n1+n2;
return Integer.toBinaryString(n);
}
}
Here is an example.