Skip to content

Commit 80d3680

Browse files
committed
♻️ [212]
1 parent 62212a0 commit 80d3680

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

212/solution.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,14 @@ var findWords = function (board, words) {
3838
visited[r][c]
3939
) return false;
4040

41-
4241
let childTrieNode = children[trieNode.getIdx(board[r][c])];
4342
str += board[r][c];
4443

45-
if (childTrieNode === null) {
46-
return false;
47-
} else if (childTrieNode.isEndOfWord) {
48-
if (!foundSet.has(str)) {
49-
foundSet.add(str)
50-
foundList.push(str)
51-
// return true;
52-
}
44+
if (childTrieNode === null) return;
45+
46+
if (childTrieNode.isEndOfWord && !foundSet.has(str)) { // If it hasn't been found yet && it is the end of the word.
47+
foundSet.add(str)
48+
foundList.push(str)
5349
}
5450

5551
visited[r][c] = true;

0 commit comments

Comments
 (0)