Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions data_structures/tries/tries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ class TrieNode {
/**
* An object that stores child nodes for each character in the alphabet.
*/
children: { [key: string]: TrieNode } = {}
children: Record<string, TrieNode> = {}

/**
* Indicates whether the node represents the end of a word.
*/
isWord: boolean = false
isWord = false
}

/**
Expand All @@ -22,11 +22,6 @@ export class Trie {
*/
root: TrieNode = new TrieNode()

/**
* Creates a new Trie instance.
*/
constructor() {}

/**
* Inserts a word into the Trie.
*
Expand All @@ -51,7 +46,7 @@ export class Trie {
* If false, the method returns true only if an exact match is found.
* @returns True if the word (or prefix) is found in the Trie; otherwise, false.
*/
public find(word: string, isPrefixMatch: boolean = false): boolean {
public find(word: string, isPrefixMatch = false): boolean {
return this.searchNode(this.root, word, isPrefixMatch)
}

Expand Down