Serialize and Deserialize a Dictionary Trie

Asked at Snowflake · Coding Questions · Difficulty: Medium · Last asked Dec 10, 2025

A dictionary trie (prefix tree) stores a set of lowercase words. Each node maps a letter to a child node and has a flag that says whether the path from the root to that node spells a word. Build a codec that turns such a trie into one string and rebuilds an identical trie from that string, for example to save it to a file and load it later.

Loading the problem…