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
November 29, 20260
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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...