top of page

Multiply Two Strings

  • Shreyas Naphad
  • Jun 17, 2024
  • 1 min read

Problem Statement: Given two non-negative integers represented as strings, return the product of these numbers as a string.


Example 1:

Input: num1 = "2", num2 = "3"

Output: "6"

Example 2:

Input: num1 = "123", num2 = "456"

Output: "56088"

 

Solution:

To multiply two strings, we replicate the multiplication process manually, similar to how we do it by hand. We use an array to store intermediate results and then convert it back to a string.



Time Complexity: O(m x n)

Space Comlexity: O(m + n)

Comments


©2025 by DevSparks.

bottom of page