Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

Boss fightThe Board of Whispers

Learn
Play
Prove
Problem context and objectives
Mission briefing

Rune decoder · Thousands of spells share the same opening symbols

Reuse shared prefixes to complete the requested spell: The Board of Whispers.

Checking every full spell makes each keystroke feel slow.

How you win

  1. 1Recognize when Trie-pruned board DFS matches the clues
  2. 2Keep this true after every move: the DFS path spells exactly the trie prefix at the current node and contains no repeated board cell
  3. 3Reach the result within O(rows times cols times 4 to the maximum word length) worst case

Rules and pressure

  • Target cost: O(rows times cols times 4 to the maximum word length) worst case
  • State rule: the DFS path spells exactly the trie prefix at the current node and contains no repeated board cell
Lesson 1 of 3

Live algorithm trace

Trie-pruned board DFS

Complete execution
1 of 8
o
a
a
n
e
t
a
e
i
h
k
r
i
f
l
v

Build one trie that shares every candidate word prefix.

1build one trie for all words
2start DFS at every board cell
3reject if the cell has no trie child
4record a word marker
5mark the cell visited
6explore four neighbors
7restore the cell
8return found words
words = oath, pea, eat, rainrootEdges = o, p, e, r
Truth to preserve / Cost target
Truth to preserve

the DFS path spells exactly the trie prefix at the current node and contains no repeated board cell

Cost target

O(rows times cols times 4 to the maximum word length) worst case

Build one trie for all candidate words, then start DFS from every board cell. A missing trie edge rejects the entire path immediately, while visited marking prevents one cell from being reused in the same word.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead