Longest Word in Dictionary
Signals to notice
Brute force first
Sort words, for each word check if all prefixes exist — with hash set. Works but doesn't exploit the structure. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
The key insight
Build a trie from all words. DFS the trie: only follow branches where isEnd is true at each step (each prefix must be a complete word). The deepest valid path is the longest word. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
What must stay true
A word is 'buildable' if every prefix of it is also in the dictionary. In the trie, this means every node along the path must be marked as a word end. As long as that statement keeps holding, you can trust the steps built on top of it.
Easy way to go wrong
Not handling ties — when multiple words have the same length, return the lexicographically smallest. DFS with alphabetical child ordering naturally handles this. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.