Skip to content
BytePatterns

Multiply Digit Strings

MediumStrings#digit-arithmetic#carry-propagation~30m

Problem

Two non-negative whole numbers are given as text, most significant digit first, and may be far too long to fit in a machine integer. Return their product, also as text. Converting the inputs to built-in numbers is not allowed, and the result must carry no leading zeros.

Examples

Input:  a = "123", b = "456"
Output: "56088"
Input:  a = "9", b = "99"
Output: "891"
Why:    the carry out of the last column adds a digit
Input:  a = "0", b = "52"
Output: "0"
Why:    edge case, a zero factor must not produce a padded result

Hints

0 / 3

Stuck on the idea rather than the code? String Basics covers it.