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

Function search

javascript/0115-distinct-subsequences.js:92–106  ·  view source on GitHub ↗
(s, t, tabu)

Source from the content-addressed store, hash-verified

90};
91
92var search = (s, t, tabu) => {
93 for (let r = s.length - 1; 0 <= r; r--) {
94 /* Time O(N) */
95 for (let c = t.length - 1; 0 <= c; c--) {
96 /* Time O(M) */
97 const left = tabu[r + 1][c];
98
99 const isEqual = s[r] === t[c];
100
101 const right = isEqual ? tabu[r + 1][c + 1] : 0;
102
103 tabu[r][c] = left + right; /* Space O(N * M) */
104 }
105 }
106};
107
108/**
109 * DP - Bottom Up

Callers 1

numDistinctFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected