pattern is a string of letters and words is a list of words. Return True if the words follow the pattern: each letter of the pattern stands for exactly one word, and each word is matched by exactly one letter. For example the pattern "abba" matches ["dog", "cat", "cat", "dog"] but not ["dog", "cat", "cat", "fish"] (a and b would both... a would need two words) and not ["dog", "dog", "dog", "dog"] (a and b would share one word).
The pattern and the list must have the same length.
Example 1
Input:
word_pattern('abba', ['dog', 'cat', 'cat', 'dog'])
Output:
True
Example 2
Input:
word_pattern('abba', ['dog', 'dog', 'dog', 'dog'])
Output:
False
0 <= len(pattern), len(words) <= 10**5No results yet
Run your code to check it against the examples, or submit to run every test.