by floxy · 4mo ago · 0 comments
1234567890
x 111111
------------
1234567890
12345678900
123456789000
1234567890000
12345678900000
+ 123456789000000
-----------------
137,174,072,825,790
...looks like O(n^2).If additions were truly free, an even easier optimal algorithm would just be repeated addition involving zero multiplications.
Memoizing number-by-digit multiplication doesn't make multiplication O(1) because one must still do an N-digit addition (which is O(N)) for each digit.