deno.land / x / masx200_leetcode_test@10.6.5 / longest-word-in-dictionary / PrefixTreeSearchPrefixEach.ts

PrefixTreeSearchPrefixEach.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { PrefixTree } from "../implement-trie-prefix-tree/PrefixTree.ts";
export function PrefixTreeSearchPrefixEach( root: PrefixTree, prefix: string, // each = false,): PrefixTree | undefined { const each = true; let node = root; for (const ch of prefix) { const next = node.children.get(ch); if (!next) { return; }
node = next; if (each && !node.isEnd) { return; } } return node;}
masx200_leetcode_test

Version Info

Tagged at
a year ago