Skip to content
Decoder

Multiply Strings

Medium

Problem

num1 and num2 are non-negative integers written as decimal strings. Return their product, also as a string. Do not convert the inputs to integers directly or use a big-integer library: multiply digit by digit.

Example 1

Input
num1 = "2", num2 = "3"
Output
"6"

Example 2

Input
num1 = "123", num2 = "456"
Output
"56088"

Example 3

Input
num1 = "0", num2 = "52"
Output
"0"

Constraints

  • 1 <= num1.length, num2.length <= 200
  • num1 and num2 consist of digits only.
  • Neither number has leading zeros, except the number 0 itself.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.