← All problems
Word Pattern (bijection check)
Given a pattern string and a space-separated word string, check whether the pattern bijectively maps to the words — e.g. pattern 'abba' matches 'dog cat cat dog' but not 'dog cat cat fish'.
Complexity
Time O(n), Space O(n)
Common pitfalls
- Checking only one direction
- Length mismatch ignored
Your solution
Log in to save your code and track progress.