Lesson overview · Free interview practice

Tries

Understand trie data structures and their use in efficient searching.

Topics in the full lesson
  • Concept and Use Cases
  • When to Use
  • Time and Space Complexity
  • Trie Operations and Methods
  • Practical Tips and Tricks
  • Common Gotchas
  • Advanced Topics
  • Trie Algorithms
  • Interview Tips and Tricks
  • Common Mistakes

Practice Problems

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Completion marks record your own progress, not an automatically checked result. The task type does not determine whether it is optional.

CodingMedium

Word Break

Question

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. The same dictionary word may be reused any number of times.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Design a WordDictionary supporting addWord(word) and search(word), where search may contain the wildcard . that matches any single letter. search returns true if at least one added word matches.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Design and implement a data structure that efficiently stores and retrieves words based on their prefixes, allowing for fast lookup and insertion operations.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Design an in-memory file system supporting four operations: ls(path) returns a file's name if path is a file, or a directory's child names in lexicographic order if it is a directory; mkdir(path) creates a directory, creating any missing intermediate directories; addContentToFile(filePath, content) creates the file if it does not exist and appends content; and readContentFromFile(filePath) returns the file's full content.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Tries material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium