Get String to Remove
You are given a string S.
You can use your mouse only once to place the mouse pointer on any position in the string and use the Backspace key on your keyboard.
You have to determine if a string X can be obtained by performing such an operation.
If it is possible, print the string that will be removed by using Backspace. Else, print -1.
Note: You are allowed to press the Backspace key multiple times but not allowed to use the mouse more than one time.
Complete the function getStringToRemove in the editor.
getStringToRemove has the following parameters:
- 1.
String S: the original string - 2.
String X: the target string to obtain
Returns
String: the string of characters that need to be removed to obtain the string X from S, if possible; otherwise, "-1"
1Example 1
Constraints
Limits and guarantees your solution can rely on.
X.length <= S.length