pattern of lowercase Latin letters and a sentence sentence made of words separated by single spaces.
The sentence fits the pattern when it has exactly as many words as the pattern has letters and letters and words correspond one to one: equal letters stand for equal words and different letters stand for different words. The letter at position i stands for the i-th word.
Return True if the sentence fits the pattern, and False otherwise.pattern="xyyx", sentence="red blue blue red" → True
x ↔ red and y ↔ blue: a one-to-one match, so the answer is True.
pattern="xyz", sentence="sun sun moon" → False
x and y are different letters but would both stand for sun, which is not allowed, so the answer is False.
pattern="aab", sentence="go go go" → False
pattern consists of lowercase Latin letterssentence consists of lowercase Latin letters and spacespattern="xyyx", sentence="red blue blue red"
True
Run checks the first 3 tests in your browser. Submit checks all 150 tests on the server, hidden ones included.