Question: Language Java 1 5 Invironment Question 1 4 Two strings are said to be the same if they are of the same length and have
Language Java
Invironment
Question
Two strings are said to be the same if they are of the same length and have the same character at each index. Backspacing in a string removes the previous character in the string.
Given two strings containing lowercase English letters and the character which represents a backspace key, determine if the two final strings are equal. Return if they are equal or if they are not. Note that backspacing an empty string results in an empty string.
Example
axbd##
In the first string, one and one are backspaced over. The first string becomes axbc. The second string also becomes axbc. The answer is
Function Description
Complete the function compareStrings in the editor below.
compareStrings has the following parameters:
string : the first string
string s; the second string
Returns
int: either or
Constraints
length of ~~
length of
Both s and contain lowercase English letters andor the character # only.
Input Format For Custom Testing
The first line contains a string, s The second line contains a string,
Sample Case
Sample Input For Custom Testing
yficel
yyok"ppiey
Sample Output
Explanation
Both the strings s and result in after processing backspaces.
grad Sample Case
Sample Input For Custom Testing
hacellkkil
hblliackkH
Sample Output
Explanation
The first string becomes "hack" while the second string becomes acComplete the 'comparestrings' function below.The function is expected to return an InTEGER.The function accepts following parameters:STRING s STRING public static int comparestringstring s String sString processeds processstring ;strting processeds processstring ;
return processedsequals:;
pubtic class solution ti
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
