MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / insert

Method insert

src/class044/Code02_TrieTree.java:33–45  ·  view source on GitHub ↗
(String word)

Source from the content-addressed store, hash-verified

31 }
32
33 public static void insert(String word) {
34 int cur = 1;
35 pass[cur]++;
36 for (int i = 0, path; i < word.length(); i++) {
37 path = word.charAt(i) - 'a';
38 if (tree[cur][path] == 0) {
39 tree[cur][path] = ++cnt;
40 }
41 cur = tree[cur][path];
42 pass[cur]++;
43 }
44 end[cur]++;
45 }
46
47 public static int search(String word) {
48 int cur = 1;

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected