MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / multiply

Function multiply

javascript/0043-multiply-strings.js:9–19  ·  view source on GitHub ↗
(num1, num2)

Source from the content-addressed store, hash-verified

7 * @return {string}
8 */
9var 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
21var initBuffer = (num1, num2) => {
22 const size = num1.length + num2.length;

Callers

nothing calls this directly

Calls 3

initBufferFunction · 0.85
multiplicationFunction · 0.85
removeLeadingZeroFunction · 0.85

Tested by

no test coverage detected