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