Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pairRemoval ( String , String, String ) This is a public static function that takes three Strings as arguments and returns a String. You will
pairRemovalString String, String
This is a public static function that takes three Strings as arguments and returns a String.
You will be given three strings, the first string is a sentence known as text that contains at least one occurrence of left pattern and right pattern. The second and third arguments of the function are the left and right patterns respectively. Left pattern and right pattern are single characters strings that you are attempting to remove from the string. Your goal is to remove only the patterns when the left pattern has an equal number of corresponding right patterns. The patterns are removed in pairs only when there is a balanced number of left and right patterns. The patterns may be nested within the text and there is no guarantee that a left pattern will occur before the right pattern in java.
Arguments:
String text The string with the substring to be removed
String leftPattern A pattern that the substring must start with
String rightPatternA pattern that the substring must end with
returns String The given text with the paired patterns removed
Example:
textMuscatmecum tollgatepoultry quarrymen pantheon asteria
leftPattern
rightPattern
returnMuscat mecum tollgate poultry quarrymen asteria
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started