MCPcopy Create free account
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / Trie

Class Trie

graphs/boggle-board.js:2–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1// Time O (ws + nm*8^s) | Space O(nm + ws)
2class Trie {
3 constructor() {
4 this.root = {};
5 this.endSymbol = "*";
6 }
7 add(string) {
8 let currentNode = this.root;
9 for (const char of string) {
10 if (!currentNode.hasOwnProperty(char)) currentNode[char] = {};
11 currentNode = currentNode[char];
12 }
13 currentNode[this.endSymbol] = string;
14 }
15}
16
17function boggleBoard(board, words) {
18 const finalWords = {};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected