15% off all plans & roadmaps Use code
See plansLeetCode 43 · Solution & editorial
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Multiply Strings is a String Manipulation Patterns problem, in the Multiply Strings (Manual Simulation) subpattern. The pattern covers palindrome checking, anagram detection, pattern matching, and string conversion
Learn to multiply large numbers represented as strings using manual simulation of multiplication.
The reference solution runs in O(m * n) time and O(m + n) space.
Multiply Strings has been reported in interviews at Facebook, Microsoft, Amazon, Square, Apple, Bloomberg, Two Sigma, ByteDance.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Multiply Strings is a String Manipulation Patterns problem, in the Multiply Strings (Manual Simulation) subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.