Problem context and objectives
Mission briefing
Rune decoder · Thousands of spells share the same opening symbols
Reuse shared prefixes to complete the requested spell: Shared Glyphs.
Checking every full spell makes each keystroke feel slow.
How you win
- 1Recognize when Prefix search matches the clues
- 2Keep this true after every move: every accepted character belongs to every word at that position
- 3Reach the result within O(total characters)
Rules and pressure
- Target cost: O(total characters)
- State rule: every accepted character belongs to every word at that position
Lesson 1 of 3
Live algorithm trace
Prefix search
Complete execution1 of 5
flower
word
flow
flight
Use the first word as the initial candidate prefix.
1
prefix = first word2
shrink until each word starts with prefix3
return prefixprefix = flower
Truth to preserve / Cost target
Truth to preserve
every accepted character belongs to every word at that position
Cost target
O(total characters)
A trie shares paths for shared prefixes. Before building the full tree, the same idea can be practiced by walking character columns until the words disagree.
Your call · What should guide every step of this algorithm?