Tap here to switch tabs
Problem
Submissions

Problem: Match Substring After Replacement

Try to solve the Match Substring After Replacement problem.

Statement

You are given two strings, s and sub, along with a 2extD2 ext{D} character array mappings where mappings[i] =[extoldi,extnewi]= [ ext{old}_i, ext{new}_i] indicates that any occurrence of the character $ ext{old}_i$ in sub can be replaced with $ ext{new}_i$. Each character in sub may be replaced at most once, and characters in s cannot be replaced.

Return true if it is possible to make sub a substring of s after replacing zero or more characters in sub using the given mappings. Otherwise, return false.

Note: A substring is a contiguous non empty sequence of characters within a string.

Constraints:

  • 1≤1 \leq sub.length ≤\leq s.length ≤5000\leq 5000

  • 0≤0 \leq mappings.length ≤1000\leq 1000

  • mappings[i].length =2= 2

  • $ ext{old}_i \neq ext{new}_i$

  • s and sub consist of uppercase and lowercase English letters and digits.

  • $ ext{old}_i$ and $ ext{new}_i$ are either uppercase or lowercase English letters or digits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Match Substring After Replacement

Try to solve the Match Substring After Replacement problem.

Statement

You are given two strings, s and sub, along with a 2extD2 ext{D} character array mappings where mappings[i] =[extoldi,extnewi]= [ ext{old}_i, ext{new}_i] indicates that any occurrence of the character $ ext{old}_i$ in sub can be replaced with $ ext{new}_i$. Each character in sub may be replaced at most once, and characters in s cannot be replaced.

Return true if it is possible to make sub a substring of s after replacing zero or more characters in sub using the given mappings. Otherwise, return false.

Note: A substring is a contiguous non empty sequence of characters within a string.

Constraints:

  • 1≤1 \leq sub.length ≤\leq s.length ≤5000\leq 5000

  • 0≤0 \leq mappings.length ≤1000\leq 1000

  • mappings[i].length =2= 2

  • $ ext{old}_i \neq ext{new}_i$

  • s and sub consist of uppercase and lowercase English letters and digits.

  • $ ext{old}_i$ and $ ext{new}_i$ are either uppercase or lowercase English letters or digits.