Tap here to switch tabs
Problem
Submissions

Problem: Find and Replace Pattern

med
30 min
Try to solve the Find and Replace Pattern problem.

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

med
30 min
Try to solve the Find and Replace Pattern problem.

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.