/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 input strings 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 = "321", str_num_b = "654"

Output: "209934"

Explanation: 321 * 654 = 209934

Example 3

Input: str_num_a = "0", str_num_b = "999"

Output: "0"

Explanation: 0 * 999 = 0

Constraints

  • 1 <= len(str_num_a) <= 200
  • 1 <= len(str_num_b) <= 200
  • str_num_a and str_num_b consist of digits only
  • str_num_a and str_num_b do not contain leading zeros except for the number 0 itself
Python (current runtime)

Case 1

Input: str_num_a = "15", str_num_b = "20"

Expected: "300"

Case 2

Input: str_num_a = "100", str_num_b = "100"

Expected: "10000"

Case 3

Input: str_num_a = "999", str_num_b = "1"

Expected: "999"

Case 4

Input: str_num_a = "50", str_num_b = "0"

Expected: "0"

Case 5

Input: str_num_a = "12", str_num_b = "12"

Expected: "144"