#290

Word Pattern

pupil · 480 · lc easy +27 · 43.9% accepted · 7,951 likes · top 26%

play →

Description

Given a pattern string and a string s, determine whether s obeys the same pattern.

A full match requires a one-to-one correspondence (bijection) where:

- 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.

Code

1
2
3