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

Function isInterleave

javascript/0097-interleaving-string.js:10–18  ·  view source on GitHub ↗
(s1, s2, s3, i = 0, j = 0, res = '')

Source from the content-addressed store, hash-verified

8 * @return {boolean}
9 */
10var isInterleave = (s1, s2, s3, i = 0, j = 0, res = '') => {
11 const isBaseCase1 = s3.length !== s1.length + s2.length;
12 if (isBaseCase1) return false;
13
14 const isBaseCase2 = res === s3 && i == s1.length && j == s2.length;
15 if (isBaseCase2) return true;
16
17 return dfs(s1, s2, s3, i, j, res); /* Time O(2^(N + M)) | Space O(N + M) */
18};
19
20var dfs = (s1, s2, s3, i, j, res, ans = false) => {
21 const hasLeft = i < s1.length;

Callers 1

dfsFunction · 0.70

Calls 4

dfsFunction · 0.70
initMemoFunction · 0.70
initTabuFunction · 0.70
searchFunction · 0.70

Tested by

no test coverage detected