MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / getLast

Method getLast

java/0208-implement-trie-prefix-tree.java:26–36  ·  view source on GitHub ↗
(String word)

Source from the content-addressed store, hash-verified

24
25 //helper method
26 public Node getLast(String word) {
27 Node curr = root;
28 for (char x : word.toCharArray()) {
29 if (curr.children[x - 'a'] == null) {
30 return null;
31 }
32
33 curr = curr.children[x - 'a'];
34 }
35 return curr;
36 }
37
38 public boolean startsWith(String prefix) {
39 Node res = getLast(prefix);

Callers 3

searchMethod · 0.95
startsWithMethod · 0.95
getLineMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected