pattern and a string
s, find if
s 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
Input: pattern = "abba", s = "dog cat cat dog" Output: true
Input: pattern = "abba", s = "dog cat cat fish" Output: false
Input: pattern = "aaaa", s = "dog cat cat dog" Output: false
Input: pattern = "abba", s = "dog dog dog dog" Output: false
1 <= pattern.length <= 300
patterncontains only lower-case English letters.
1 <= s.length <= 3000
scontains only lower-case English letters and spaces
sdoes not contain any leading or trailing spaces.
sare separated by a single space.