← 返回 snapchat 的题目列表Replace All Pattern Occurrences with a Single Character
类型:online_judge
snapchat
Given a string and an array of matching patterns, replace all occurrences of the Patterns in the string with a specified character and return the replaced string.
Input:
A string s.
A string array patterns representing the patterns to be replaced.
A string replacement representing the character to replace patterns with. For example, s = "abcdefgh", patterns = ["bc", "de"], replacement = "x"
Output:
Return a string where all occurrences of the patterns have been replaced with the specified character.
Example:
Input: s = "abcdefgh", patterns = ["bc", "de"], replacement = "x"
Output: "axfgh"
Constraints:
The length of s does not exceed 1000.
The length of each string in patterns does not exceed 100.
replacement is a single character.
Example
Input
"abcdefgh"
["bc", "de"]
"x"