Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 429 |

@iamronak | 424 |

@imnm | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

Given two binary strings** A** and **B** consisting of only 0s and 1s. Find the resultant string after adding the two Binary Strings.

**Note: **The input strings may contain leading zeros but the output string should not have any leading zeros.

**Example 1:**

**Input:**
A = "1101", B = "111"
**Output:** 10100
**Explanation**:
1101
+ 111
10100

â€‹**Example 2:**

**Input**:
A = "10", B = "01"
**Output:** 11
**Explanation**:
10
+ 01
11

**User Task:**

You don't need to read input or print anything. Your task is to complete the function **addBinary() **which takes 2 binary string A and B and **returns **a binary string denoting the addition of both the strings.

**Expected Time Complexity: **O(max(|A|, |B|)).

**Expected Auxiliary Space: **O(max(|A|, |B|)) (for output string).

**Constraints:**

1 <= |A|, |B| <= 1000000

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Add Binary Strings

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.