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

Function checkWord

javascript/0139-word-break.js:124–136  ·  view source on GitHub ↗
(s, wordSet, end, tabu)

Source from the content-addressed store, hash-verified

122};
123
124var checkWord = (s, wordSet, end, tabu) => {
125 for (let start = 0; start < end; start++) {
126 /* Time O(N) */
127 const word = s.slice(start, end); /* Time O(N) | Space O(N) */
128
129 const canBreak = tabu[start] && wordSet.has(word);
130 if (!canBreak) continue;
131
132 tabu[end] = true;
133
134 return;
135 }
136};
137
138/**
139 * Tree Traversal - BFS

Callers 1

canBreakFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected