Word Pattern

Easy · Hashing · about 10 minutes

Asked at Microsoft, Google, Amazon, Bloomberg, Uber.

Given a pattern of lowercase letters and a string s of words separated by single spaces, return true if s follows the pattern: there is a one-to-one mapping between pattern letters and words, so the same letter always maps to the same word and different letters map to different words.

Related guides