We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62212a0 commit 80d3680Copy full SHA for 80d3680
212/solution.js
@@ -38,18 +38,14 @@ var findWords = function (board, words) {
38
visited[r][c]
39
) return false;
40
41
-
42
let childTrieNode = children[trieNode.getIdx(board[r][c])];
43
str += board[r][c];
44
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
- }
+ if (childTrieNode === null) return;
+
+ if (childTrieNode.isEndOfWord && !foundSet.has(str)) { // If it hasn't been found yet && it is the end of the word.
+ foundSet.add(str)
+ foundList.push(str)
53
}
54
55
visited[r][c] = true;
0 commit comments