Given a pattern and a string s, return true when s follows the same pattern.
pattern
s
true
There must be a bijection between a letter in pattern and a non-empty word in s.
pattern = "abba", s = "dog cat cat dog"
pattern = "abba", s = "dog cat cat fish"
false
1 <= pattern.length <= 300 1 <= s.length <= 3000 Words in `s` are separated by single spaces.
Topics
Implement wordPattern in the editor and return the answer — printing it is never graded.
wordPattern
Problem 35 of 1146 in the arena