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

Function hasMatch

javascript/0097-interleaving-string.js:167–181  ·  view source on GitHub ↗
(s1, s2, s3, i, j, tabu)

Source from the content-addressed store, hash-verified

165};
166
167var hasMatch = (s1, s2, s3, i, j, tabu) => {
168 const isBaseCase1 = i === 0 && j === 0;
169 if (isBaseCase1) return true;
170
171 const isBaseCase2 = i === 0;
172 if (isBaseCase2) return getRight(i, j, s2, s3, tabu);
173
174 const isBaseCase3 = j === 0;
175 if (isBaseCase3) return getLeft(i, j, s1, s3, tabu);
176
177 const left = getLeft(i, j, s1, s3, tabu);
178 const right = getRight(i, j, s2, s3, tabu);
179
180 return left || right;
181};
182
183var getLeft = (i, j, s1, s3, tabu) =>
184 (tabu[i - 1][j] && s1[i - 1]) === s3[i + j - 1];

Callers 1

searchFunction · 0.85

Calls 2

getRightFunction · 0.70
getLeftFunction · 0.70

Tested by

no test coverage detected