Hash Strategies Target: 10s
Same as search but returns True when you reach the end of the prefix — no need to check is_end.
def starts_with(root, prefix):
node = root
for ch in prefix:
if ch not in node.children:
return False
node = node.children[ch]
return True
Type it from memory. Go.