Skip to content
playdsa
Preferences

Make yourself comfortable.

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

Theme
Advanced settings

The Wildcard Vault

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 Wildcard Vault.

Checking every full spell makes each keystroke feel slow.

How you win

  1. 1Recognize when Trie wildcard DFS matches the clues
  2. 2Keep this true after every move: each DFS state represents one trie node after matching exactly pattern[0:index]
  3. 3Reach the result within O(branches explored times pattern length)

Rules and pressure

  • Target cost: O(branches explored times pattern length)
  • State rule: each DFS state represents one trie node after matching exactly pattern[0:index]
Lesson 1 of 3

Live algorithm trace

Trie wildcard DFS

Complete execution
1 of 6
bad
dad
mad
.ad
pattern

Build three first-letter branches for bad, dad, and mad.

1build a trie of words
2dfs(node, index)
3if index == length: return node.isWord
4if pattern[index] is literal: follow one child
5if dot: try every child
6return whether any branch matches
roots = b, d, mpattern = .ad
Truth to preserve / Cost target
Truth to preserve

each DFS state represents one trie node after matching exactly pattern[0:index]

Cost target

O(branches explored times pattern length)

Literal characters follow one trie edge. A dot wildcard must try every child, but each branch still advances exactly one pattern position and succeeds only at a marked word ending.

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