(num1, num2)
| 7 | * @return {string} |
| 8 | */ |
| 9 | var multiply = (num1, num2) => { |
| 10 | const isZero = num1 === '0' || num2 === '0'; |
| 11 | if (isZero) return '0'; |
| 12 | |
| 13 | const buffer = initBuffer(num1, num2); /* | Space (N + M) */ |
| 14 | |
| 15 | multiplication(num1, num2, buffer); /* Time O(N * M) */ |
| 16 | removeLeadingZero(buffer); /* Time O(N + M) | Time O(N + M)*/ |
| 17 | |
| 18 | return buffer.join(''); /* Time O(N + M) | Space O(N + M) */ |
| 19 | }; |
| 20 | |
| 21 | var initBuffer = (num1, num2) => { |
| 22 | const size = num1.length + num2.length; |
nothing calls this directly
no test coverage detected