All problems

Multiply Strings

Medium · math

Two non-negative whole numbers are given as strings of decimal digits, num1 and num2. Return their product, also as a string.

The numbers can have up to 200 digits, more than a built-in integer type can hold. So work digit by digit, the way you multiply on paper: do not turn a whole string into a number and do not use a big-number library.

Neither input has leading zeros, except that the number zero is written "0". The answer must follow the same rule.

Examples

Example 1

Input: num1 = "2", num2 = "3"

Output: "6"

Example 2

Input: num1 = "123", num2 = "45"

Output: "5535"

123 * 45 = 5535.

Example 3

Input: num1 = "0", num2 = "812"

Output: "0"

Anything multiplied by zero is zero, written as a single 0.

Constraints