Practice Match Substring After Replacement
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given s, sub, and directed character mappings [old, new], you may replace any occurrence of old in sub with new. Each character position may be replaced at most once, so mappings cannot be chained at the same position or reversed unless separately supplied. Return whether sub can become a contiguous substring of s after zero or more replacements.
Source: Match Substring After Replacement on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "fool3e7bar", sub = "leet", mappings = [["e","3"],["t","7"],["t","8"]]
true
# Example 2
s = "fooleetbar", sub = "f00l", mappings = [["o","0"]]
false
# Example 3
s = "Fool33tbaR", sub = "leetd", mappings = [["e","3"],["t","7"],["t","8"],["d","b"],["p","b"]]
true
Constraints
Related LeetCode Problems
Practice more problems similar to Match Substring After Replacement.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.