04 Try it yourself Interactive
The Insert tab builds the trie from an empty root, one character per press — plus a press to arrive at the root of each word and a press to set its end-of-word flag — and tells you each time whether a node was created or reused. The Query tab walks a string through the trie you just built and stops to show where search and startsWith part ways. Nothing moves until you press Next.