Skip to content
BASA DSA

Multiply Strings

MediumMath & Geometry

Multiply two nonnegative integers given as decimal strings and return a decimal string. Do not convert the whole input strings to big integers.

Example 1

Input
num1 = "12"
num2 = "34"
Output
"408"

Explanation

1234=1230+12*4=360+48=408.

Example 2

Input
num1 = "0"
num2 = "987"
Output
"0"

Explanation

Multiplying by zero gives the canonical string 0.

Example 3

Input
num1 = "99"
num2 = "99"
Output
"9801"

Explanation

99*99=9801; decimal carries produce four digits.

Constraints

  • 1 <= string lengths <= 200
  • Strings contain digits and have no leading zeros except zero itself

Function contractmultiplyArguments: json, json
Loading draft…
SolutionRuns on your device
Loading draft…