MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / hasPrefix

Method hasPrefix

java/Tries/DesignATrie.java:48–59  ·  view source on GitHub ↗
(String prefix)

Source from the content-addressed store, hash-verified

46 }
47
48 public boolean hasPrefix(String prefix) {
49 TrieNode node = this.root;
50 for (char c : prefix.toCharArray()) {
51 if (!node.children.containsKey(c)) {
52 return false;
53 }
54 node = node.children.get(c);
55 }
56 // Once we've traversed the nodes corresponding to each
57 // character in the prefix, return True.
58 return true;
59 }
60}

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected