| English | 简体中文 |
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
1 <= pattern.length <= 300
patterncontains only lower-case English letters.
1 <= s.length <= 3000
scontains only lowercase English letters and spaces
sdoes not contain any leading or trailing spaces.
- All the words in
sare separated by a single space.