liked this video? Click here / @codebix1096 join our Facebook group :- / 258049468776636 problem :- leetcode.com/problems/add-bin... code :- github.com/luckykumardev/leet...
Working C++ code ✅🙂 class Solution { public: string addBinary(string a, string b) { int aSize = a.size(); int bSize = b.size(); int i = 0; int carry = 0; string ans = ""; while( i
u need to use String Builder and reverse it like this; class Solution { public String addBinary(String a, String b) { int carry = 0; int aLen = a.length(); int bLen = b.length(); int i = 0; StringBuilder ans = new StringBuilder();
Working C++ code ✅🙂 class Solution { public: string addBinary(string a, string b) { int aSize = a.size(); int bSize = b.size(); int i = 0; int carry = 0; string ans = ""; while( i
Working C++ code ✅🙂 class Solution { public: string addBinary(string a, string b) { int aSize = a.size(); int bSize = b.size(); int i = 0; int carry = 0; string ans = ""; while( i
Working C++ code ✅🙂 class Solution { public: string addBinary(string a, string b) { int aSize = a.size(); int bSize = b.size(); int i = 0; int carry = 0; string ans = ""; while( i
after getting stucked at the same problem and watching many complicated videos, i found the right video...
Nice explanation!! Keep uploading more videos on leetcode problems
Wonderful Explanation.
NICE explaination. Subscribed.
Awesome Explanation Sir,....Sir Multiply Strings ka ek explanation video upload krdijiye
Another video well explained. Please keep up the good work..Thank you so much.
Thanks, will do!
Great 🔥🎉
Working C++ code ✅🙂
class Solution {
public:
string addBinary(string a, string b) {
int aSize = a.size();
int bSize = b.size();
int i = 0;
int carry = 0;
string ans = "";
while( i
u need to use String Builder and reverse it like this;
class Solution {
public String addBinary(String a, String b) {
int carry = 0;
int aLen = a.length();
int bLen = b.length();
int i = 0;
StringBuilder ans = new StringBuilder();
while(i
Is it necessary to use StringBuilder?
@@pravalika1274 no it's not required
Wow❣️
Awesome
like++; nice explanation.👍
your explaination is great but this code is not passing all the test cases ! please check before your explain
Working C++ code ✅🙂
class Solution {
public:
string addBinary(string a, string b) {
int aSize = a.size();
int bSize = b.size();
int i = 0;
int carry = 0;
string ans = "";
while( i
string addBinary(string a, string b) {
string s = "";
int n1 = a.length() - 1, n2 = b.length() - 1;
int carry = 0;
while(n1 >= 0 && n2 >= 0)
{
if(a[n1] == '0' && b[n2] == '0')
{
if(carry == 0)
{
s = '0' + s;
}
else
{
s = '1' + s;
carry = 0;
}
}
else if(a[n1] == '1' && b[n2] == '1')
{
if(carry == 0)
{
s = '0' + s;
carry = 1;
}
else
{
s = '1' + s;
}
}
else
{
if(carry == 0)
{
s = '1' + s;
}
else
{
s = '0' + s;
}
}
--n1;
--n2;
}
while(n1 >= 0)
{
if(carry == 0)
{
s = a[n1] + s;
}
else
{
if(a[n1] == '0')
{
s = '1' + s;
carry = 0;
}
else
{
s = '0' + s;
}
}
--n1;
}
while(n2 >= 0)
{
if(carry == 0)
{
s = b[n2] + s;
}
else
{
if(b[n2] == '0')
{
s = '1' + s;
carry = 0;
}
else
{
s = '0' + s;
}
}
--n2;
}
if(carry == 1)
{
s = '1' + s;
}
return s;
}
program doesn't run 🙄😏
bhai reverse krni pdegi string
Working C++ code ✅🙂
class Solution {
public:
string addBinary(string a, string b) {
int aSize = a.size();
int bSize = b.size();
int i = 0;
int carry = 0;
string ans = "";
while( i
Your code is not working.
Working C++ code ✅🙂
class Solution {
public:
string addBinary(string a, string b) {
int aSize = a.size();
int bSize = b.size();
int i = 0;
int carry = 0;
string ans = "";
while( i