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

Function initTabu

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

Source from the content-addressed store, hash-verified

75};
76
77var initTabu = (s, t) => {
78 const tabu = new Array(s.length + 1)
79 .fill() /* Time O(N) | Space O(N) */
80 .map(() => new Array(t.length + 1)); /* Time O(M) | Space O(M) */
81
82 tabu[s.length].fill(0); /* | Space O(N * M) */
83
84 for (let r = 0; r <= s.length; ++r) {
85 /* Time O(N) */
86 tabu[r][t.length] = 1; /* | Space O(N * M) */
87 }
88
89 return tabu;
90};
91
92var search = (s, t, tabu) => {
93 for (let r = s.length - 1; 0 <= r; r--) {

Callers 1

numDistinctFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected