Match Words Pattern

STRING

Problem

Given a pattern string pattern and a string sentence, return true if sentence follows the same sequence as pattern. Each character in the pattern corresponds to a unique word in the sentence.

Examples

doesMatchPattern("xyx", "apple orange apple") // returns true // 'x' is 'apple' and 'y' is 'orange'. doesMatchPattern("aba", "hello world world") // returns false // 'a' and 'b' don't consistently match. doesMatchPattern("aaa", "banana banana banana") // returns true // 'a' always represents 'banana'.
Loading...