PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Two Sigma

Add two integer strings using digit-adder

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in string-based arithmetic, digit-wise addition, carry propagation, and management of arbitrarily large non-negative integers without converting entire strings to native numeric types.

  • hard
  • Two Sigma
  • Coding & Algorithms
  • Data Scientist

Add two integer strings using digit-adder

Company: Two Sigma

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

## Coding Prompt You are given a helper function: - `addDigits(a, b) -> (sumDigit, carry)` - `a` and `b` are **single decimal digits** (characters `'0'`…`'9'` or integers 0…9). - It returns the **ones digit** of `a + b` and the **carry** (0 or 1). - Example: `addDigits(7, 8) -> (5, 1)`. ### Task Implement `addStrings(num1, num2) -> string` that returns the decimal string representing `num1 + num2`. ### Requirements - `num1` and `num2` are **non-negative integers** represented as strings (no leading `+`/`-`). - You may **not** convert the entire strings to built-in integer types (assume very long inputs). - You may only use the provided `addDigits` helper for digit-wise addition. ### Examples - `addStrings("11", "123") = "134"` - `addStrings("999", "1") = "1000"` - `addStrings("0", "0") = "0"` ### Constraints - Length of each string can be up to at least \(10^5\) characters. - Time should be linear in the total number of digits.

Quick Answer: This question evaluates proficiency in string-based arithmetic, digit-wise addition, carry propagation, and management of arbitrarily large non-negative integers without converting entire strings to native numeric types.

Related Interview Questions

  • Implement Price-Time Order Matching - Two Sigma (medium)
  • Compute Piecewise Linear Interpolation - Two Sigma (medium)
  • Implement an In-Memory Database - Two Sigma (hard)
  • Merge two sorted linked lists - Two Sigma (hard)
  • Merge Two Sorted Lists - Two Sigma (hard)
Two Sigma logo
Two Sigma
Jan 6, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
4
0
Loading...

Coding Prompt

You are given a helper function:

  • addDigits(a, b) -> (sumDigit, carry)
    • a and b are single decimal digits (characters '0' … '9' or integers 0…9).
    • It returns the ones digit of a + b and the carry (0 or 1).
    • Example: addDigits(7, 8) -> (5, 1) .

Task

Implement addStrings(num1, num2) -> string that returns the decimal string representing num1 + num2.

Requirements

  • num1 and num2 are non-negative integers represented as strings (no leading + / - ).
  • You may not convert the entire strings to built-in integer types (assume very long inputs).
  • You may only use the provided addDigits helper for digit-wise addition.

Examples

  • addStrings("11", "123") = "134"
  • addStrings("999", "1") = "1000"
  • addStrings("0", "0") = "0"

Constraints

  • Length of each string can be up to at least 10510^5105 characters.
  • Time should be linear in the total number of digits.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Two Sigma•More Data Scientist•Two Sigma Data Scientist•Two Sigma Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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.