Tap here to switch tabs
Problem
Submissions

Problem: Find and Replace Pattern

Find and Replace Pattern asks you to return every word that matches a given string pattern through a one-to-one correspondence between their characters.

Statement

Given a list of strings words and a string pattern, return a list of all strings in words that match pattern. You may return the answer in any order.

A word matches the pattern if there exists a bijection between the letters in pattern and the letters in the word such that replacing every character in pattern with its mapped character produces the word. That is, every letter in pattern maps to a unique letter, and no two distinct letters in pattern map to the same letter.

Constraints:

  • 1≤1 \leq pattern.length ≤20\leq 20

  • 1≤1 \leq words.length ≤50\leq 50

  • words[i].length == pattern.length

  • pattern and words[i] consist only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find and Replace Pattern

Find and Replace Pattern asks you to return every word that matches a given string pattern through a one-to-one correspondence between their characters.

Statement

Given a list of strings words and a string pattern, return a list of all strings in words that match pattern. You may return the answer in any order.

A word matches the pattern if there exists a bijection between the letters in pattern and the letters in the word such that replacing every character in pattern with its mapped character produces the word. That is, every letter in pattern maps to a unique letter, and no two distinct letters in pattern map to the same letter.

Constraints:

  • 1≤1 \leq pattern.length ≤20\leq 20

  • 1≤1 \leq words.length ≤50\leq 50

  • words[i].length == pattern.length

  • pattern and words[i] consist only of lowercase English letters.