Problem
Given a pattern of letters and a string s of words separated by single spaces, return true if s follows the pattern: there is a one-to-one match between letters and words, so each letter always stands for the same word and no two letters stand for the same word.
Example 1
- Input
- pattern = "abba", s = "dog cat cat dog"
- Output
- true
Example 2
- Input
- pattern = "abba", s = "dog cat cat fish"
- Output
- false
Example 3
- Input
- pattern = "abba", s = "dog dog dog dog"
- Output
- false
- Why
- a and b both mean dog
Constraints
1 <= pattern.length <= 300pattern contains only lowercase English letters.1 <= s.length <= 3000s contains lowercase letters and single spaces, with no leading or trailing space.