Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 738 Bytes

README.md

File metadata and controls

42 lines (28 loc) · 738 Bytes

81.Word Pattern

Description

Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

Example1

Input: 'abba', 'dog cat cat dog'
Output: true

Example2

Input: 'abba', 'dog cat cat fish'
Output: false

Example3

Input: 'aaaa', 'dog cat cat dog'
Output: false

Example4

Input: 'abba', 'dog dog dog dog'
Output: false

Note

You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space.

From

LeetCode