/43. Multiply Strings

43. Multiply Strings

Medium
Probability43.7% acceptance

Given two non-negative integer values represented as strings, compute their product and return the result as a string. You must not use any built-in BigInteger library or convert the inputs directly to integers.

Example 1

Input: str_num_a = 7, str_num_b = 8

Output: 56

Explanation: 7 * 8 = 56

Example 2

Input: str_num_a = 15, str_num_b = 20

Output: 300

Explanation: 15 * 20 = 300

Example 3

Input: str_num_a = 0, str_num_b = 12345

Output: 0

Explanation: 0 multiplied by any number is 0

Example 4

Input: str_num_a = 999, str_num_b = 999

Output: 998001

Explanation: 999 * 999 = 998001

Constraints

  • 1 <= len(str_num_a) <= 200
  • 1 <= len(str_num_b) <= 200
  • str_num_a and str_num_b consist only of digits (0-9)
  • str_num_a and str_num_b do not have leading zeros except for the value 0
Python (current runtime)

Case 1

Input: str_num_a = '12', str_num_b = '34'

Expected: '408'

Case 2

Input: str_num_a = '100', str_num_b = '1000'

Expected: '100000'

Case 3

Input: str_num_a = '321', str_num_b = '123'

Expected: '39483'

Case 4

Input: str_num_a = '1', str_num_b = '1'

Expected: '1'

Case 5

Input: str_num_a = '50', str_num_b = '2'

Expected: '100'