Skip to main content
Easy Hash Map / Set Medium frequency

Word Pattern

Open on LeetCode

Approach Summary

Bijective mapping: map each pattern character to a word AND each word back to its character. Any mismatch → false.

How to Recognize This Pattern

  • "Does pattern match string word-for-word"
  • Need two-way map to catch both mismatch directions

Complexity Analysis

Time Complexity

O(n)

Space Complexity

O(n)

Tags

Hash Table String

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee