MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / multiply

Function multiply

javascript/0070-climbing-stairs.js:145–159  ·  view source on GitHub ↗
(prev, next)

Source from the content-addressed store, hash-verified

143};
144
145const multiply = (prev, next) => {
146 const [rows, cols] = [2, 2];
147 const matrix = new Array(rows).fill().map(() => new Array(cols).fill(0));
148
149 for (let row = 0; row < rows; row++) {
150 for (let col = 0; col < cols; col++) {
151 const left = prev[row][0] * next[0][col];
152 const right = prev[row][1] * next[1][col];
153
154 matrix[row][col] = left + right;
155 }
156 }
157
158 return matrix;
159};
160
161/**
162 * Math - Fibonacci Formula

Callers 1

powerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected