PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Add two binary strings

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency with binary arithmetic and string manipulation, focusing on carry propagation and handling of very long inputs without relying on native integer conversion.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Add two binary strings

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given two binary strings `a` and `b` (each consisting only of characters `'0'` and `'1'`). Return their sum as a binary string. ## Input - `a`: string, length `1..10^5` - `b`: string, length `1..10^5` ## Output - A string representing `a + b` in base-2, with no leading zeros unless the result is exactly `"0"`. ## Constraints / Notes - You may not convert the entire strings to built-in integers (they may exceed 64-bit limits). - Time: `O(|a| + |b|)`; extra space should be `O(|a| + |b|)` (or better). ## Example - `a = "1011"`, `b = "110"` → output: `"10001"`

Quick Answer: This question evaluates proficiency with binary arithmetic and string manipulation, focusing on carry propagation and handling of very long inputs without relying on native integer conversion.

Related Interview Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
Meta logo
Meta
Jan 5, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0
Loading...

You are given two binary strings a and b (each consisting only of characters '0' and '1'). Return their sum as a binary string.

Input

  • a : string, length 1..10^5
  • b : string, length 1..10^5

Output

  • A string representing a + b in base-2, with no leading zeros unless the result is exactly "0" .

Constraints / Notes

  • You may not convert the entire strings to built-in integers (they may exceed 64-bit limits).
  • Time: O(|a| + |b|) ; extra space should be O(|a| + |b|) (or better).

Example

  • a = "1011" , b = "110" → output: "10001"

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.