#290

Word Pattern

easy · 43.9% accepted · 7,951 likes · top 26%

hash table · string

⊣ practice⊣ quiz⊣ open on leetcode ↗

Description

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 pattern and a non-empty word in s. Specifically:

- Each letter in pattern maps to exactly one unique word in s.

- Each unique word in s maps to exactly one letter in pattern.

- No two letters map to the same word, and no two words map to the same letter.

Solution