Multiply Two Arbitrary-Length Revenue Figures Given as Strings

Last updated: November 29, 2026

Quick Overview

Two non-negative revenue figures are given as decimal strings that can be hundreds of digits long. Return their product as a string without converting either to an integer.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Two non-negative revenue figures are given as decimal strings that can be hundreds of digits long. Return their product as a string without converting either to an integer.

A Meta technical screen classic that follows string addition. The interviewer checks the grade-school multiplication index mapping, carry handling, and stripping leading zeros.

What the Interviewer Expects
  • Map digit positions i and j to result positions i + j and i + j + 1
  • Accumulate products into an integer array then normalize carries
  • Strip leading zeros and handle a zero operand
  • State O(mn) time
  • Mention Karatsuba for very long inputs
Key Topics to Cover
Grade-school multiplication
Carry propagation
Array indexing
String math
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How does Karatsuba reduce the complexity?
  • How would you multiply decimals with fractional parts?
  • What changes for negative numbers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: strings a and b of digits, no leading zeros except "0". Lengths up to a few hundred. Output: product string. No built-in big integer conversion....

High-Level Design

The product of lengths m and n has at most m + n digits. Digit a[i] times b[j] contributes to positions i + j (tens) and i + j + 1 (units) of the result array when indexed from the left.

Walk...


Submit Your Answer
Markdown supported