Multiply Strings
MediumP3Coding
num1 and num2 are non-negative integers written as decimal strings. Return their product, also as a string.
Do not convert the whole strings to integers (no BigInt, no built-in big-number multiplication); work digit by digit like long multiplication. The inputs have no leading zeros except for the number 0 itself.
Example 1
- Input
- num1 = "2", num2 = "3"
- Output
- "6"
Example 2
- Input
- num1 = "123", num2 = "456"
- Output
- "56088"
Example 3
- Input
- num1 = "0", num2 = "0"
- Output
- "0"
Constraints
- 1 <= num1.length, num2.length <= 200
- num1 and num2 contain only digits.
- No leading zeros, except the number 0.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 12. ⌘Enter runs, ⌘⇧Enter submits.