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

Method insert

tries/multi-string-search.js:61–72  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

59 }
60
61 insert(string) {
62 let currentNode = this.root;
63
64 for (let i = 0; i < string.length; i++) {
65 const letter = string[i];
66 if (!currentNode.hasOwnProperty(letter)) {
67 currentNode[letter] = {};
68 }
69 currentNode = currentNode[letter];
70 }
71 currentNode[this.endSymbol] = string;
72 }
73}
74// O(ns + bs) time | O(ns) space
75function multiStringSearch(bigString, smallStrings) {

Callers 1

multiStringSearchFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected