
Desicription
Given a pattern and a string str, find if str follows the same pattern.
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.
Example 1:
1 |
Input: pattern = "abba", str = "dog cat cat dog" |
Example 2:
1 |
Input:pattern = "abba", str = "dog cat cat fish" |
Example 3:
1 |
Input: pattern = "aaaa", str = "dog cat cat dog" |
Example 4:
1 |
Input: pattern = "abba", str = "dog dog dog dog" |
Notes:
You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space.
Solution
1 |
class { |




近期评论