deno.land / x / masx200_leetcode_test@10.6.5 / implement-trie-prefix-tree / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { PrefixTreeInsert,} from "../design-add-and-search-words-data-structure/PrefixTreeInsert.ts";import { PrefixTree } from "./PrefixTree.ts";import { PrefixTreeSearch } from "./PrefixTreeSearch.ts";import { PrefixTreeStartsWith } from "./PrefixTreeStartsWith.ts";
interface Trie { insert(word: string): void;
search(word: string): boolean;
startsWith(prefix: string): boolean;}export default Trie;function Trie(): Trie { const root: PrefixTree = PrefixTree(); function insert(word: string): void { PrefixTreeInsert(root, word); } function search(word: string) { return PrefixTreeSearch(root, word); } function startsWith(prefix: string) { return PrefixTreeStartsWith(root, prefix); } return { insert, search, startsWith };}
masx200_leetcode_test

Version Info

Tagged at
a year ago