Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

operations =
arguments =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Store words in a trie; wildcard . branches to all children.

Approach

  • addWord: standard trie insertion.
  • search: DFS over trie.
    • For normal character: follow that edge.
    • For .: try all children.

Why it works

The trie represents all stored words by prefixes; wildcard matching corresponds to exploring all possible next letters at that position.

Code
Loading...
Complexity
Time: O(L) average, O(26^L) worst-case for all '.'
Space: O(total characters inserted)
Solution
Updated: 2026-02-23

Idea

Store words in a trie; wildcard . branches to all children.

Approach

  • addWord: standard trie insertion.
  • search: DFS over trie.
    • For normal character: follow that edge.
    • For .: try all children.

Why it works

The trie represents all stored words by prefixes; wildcard matching corresponds to exploring all possible next letters at that position.

Code
Loading...
Complexity
Time: O(L) average, O(26^L) worst-case for all '.'
Space: O(total characters inserted)