Tries and prefix search

Is ca a stored word, a prefix, or both?

Examples

Worked example

Input
The trie contains car and cart only.
Expected output
A prefix only.

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

The path c → a exists, but there is no end marker at the a node.

Back to the lesson