Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

(This question is a variation of the LeetCode question 290. Word Pattern. If you haven't completed that question yet, it is recommended to solve it first.)

Given a pattern string and a list of words, for each word, determine whether it follows the given pattern or not.

A word matches the pattern if there exists a one-to-one mapping between each character in the pattern and a character in the word. In other words, every occurrence of a character in the pattern must map to the same character in the word, and no two different characters in the pattern can map to the same character in the word. Additionally, each character in the word can be mapped to only one character from the pattern.

Test Cases
Input
Output
Expected