PracHub
QuestionsCoachesLearningGuidesInterview Prep

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.

Return the binary-string sum of a and b without converting the full strings to integers.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('1011','110')

Expected Output: '10001'

Explanation: 11 + 6 = 17.

Input: ('0','0')

Expected Output: '0'

Explanation: Zero plus zero is zero.

Input: ('1111','1')

Expected Output: '10000'

Explanation: Carry propagates across all digits.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.
Last updated: Jun 27, 2026

Loading coding console...

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
  • AI Coding 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.

Related Coding 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)