MediumMath · Strings

Multiply Strings

You are given two strings num1 and num2 that represent non-negative integers. Return their product, also as a string. You may not use a big-integer library or convert the inputs to integers directly.

num1 = "3", num2 = "4" → "12"num1 = "111", num2 = "222" → "24642"

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Variables

The data structures the code is building

Long multiplication

Digits are aligned by place value, ones on the right

Time and space complexity

m, n = lengths of num1 and num2. The highlighted row is the solution being traced.

Keyboard: ← → step, Space play or pause. Up to 6 digits each, digits only, no leading zeros.