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 Glyph Index

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 Glyph Index.

Checking every full spell makes each keystroke feel slow.

How you win

  1. 1Recognize when Trie construction and lookup matches the clues
  2. 2Keep this true after every move: the current node represents exactly the characters consumed from the query
  3. 3Reach the result within O(total inserted characters + total queried characters)

Rules and pressure

  • Target cost: O(total inserted characters + total queried characters)
  • State rule: the current node represents exactly the characters consumed from the query
Lesson 1 of 3

Live algorithm trace

Trie construction and lookup

Complete execution
1 of 7
app
word
apple
apt
bat

Create one root node before inserting any word.

1root = empty node
2for each word
3walk or create one child per character
4mark the final node as a word
5for each query, walk its characters
6search also requires an end marker
7prefix only requires a complete walk
nodes = 1root = empty prefix
Truth to preserve / Cost target
Truth to preserve

the current node represents exactly the characters consumed from the query

Cost target

O(total inserted characters + total queried characters)

A trie stores one character per edge. Words with a shared prefix reuse the same path, while an end marker distinguishes a complete word from a prefix that merely leads farther.

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