Fundamentals/Word Pattern II
← PrevNext →
Given a 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 the pattern and a non-empty substring in s.
Examples
Example 1
Inputpattern = "abab", s = "redblueredblue"
Outputtrue
Example 2:
Inputpattern = "aaaa", s = "asdasdasdasd"
Outputtrue
Example 3:
Inputpattern = "aabb", s = "xyzabcxzyabc"
Outputfalse