Given a `pattern` of lowercase letters and a string `s` of words separated by single spaces, decide whether `s` follows the pattern. Following means there is a bijection: each letter maps to exactly one word, each word maps to exactly one letter, and replacing every letter of the pattern with its word gives `s`.
Given a pattern of lowercase letters and a string s of words separated by single spaces, decide whether s follows the pattern. Following means there is a bijection: each letter maps to exactly one word, each word maps to exactly one letter, and replacing every letter of the pattern with its word gives s.
Example 1:
Input: {"pattern":"abba","s":"dog cat cat dog"}
Output: true
Constraints:
1≤pattern.length≤300
pattern contains only lower-case English letters.
1≤s.length≤3000
s contains only lowercase English letters and spaces.
s has no leading or trailing spaces, and words are separated by a single space.