mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-07 09:54:53 +08:00
Add Trie.
This commit is contained in:
@ -26,7 +26,7 @@ export default class Trie {
|
||||
return lastCharacter.suggestChildren();
|
||||
}
|
||||
|
||||
doesWordExists(word) {
|
||||
doesWordExist(word) {
|
||||
return !!this.getLastCharacterNode(word);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ describe('Trie', () => {
|
||||
trie.addWord('car');
|
||||
trie.addWord('caption');
|
||||
|
||||
expect(trie.doesWordExists('cat')).toBeTruthy();
|
||||
expect(trie.doesWordExists('cap')).toBeTruthy();
|
||||
expect(trie.doesWordExists('call')).toBeFalsy();
|
||||
expect(trie.doesWordExist('cat')).toBeTruthy();
|
||||
expect(trie.doesWordExist('cap')).toBeTruthy();
|
||||
expect(trie.doesWordExist('call')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user