Pattern Recognition Drill
Medium Math & Geometry
The Problem
Given two numbers represented as strings, return their product as a string.
What approach would you use?
Think about it before scrolling down.
Result has len(n1)+len(n2) digits. Multiply each pair, add to position i+j+1. Handle carries. O(m*n).
Common Trap
Indexing: digit at position i times digit at position j contributes to result position i+j and i+j+1.