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 15
Invironment
Question 14
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 1 if they are equal or 0 if they are not. Note that backspacing an empty string results in an empty string.
Example
s2=1axbd#c#c
In the first string, one 'x' and one 'b' are backspaced over. The first string becomes axbc. The second string also becomes axbc. The answer is 1.
Function Description
Complete the function compareStrings in the editor below.
compareStrings has the following parameter(s):
string 51: the first string
string s2; the second string
Returns
int: either 0 or 1
Constraints
1 length of 512~~105
1 length of 522**105
Both s1 and s2 contain lowercase English letters and/or the character '#' only.
Input Format For Custom Testing
The first line contains a string, s1. The second line contains a string, 52.
Sample Case 0
Sample Input For Custom Testing
yficel
yyok"ppiey
Sample Output
1
Explanation
Both the strings s1 and s2 result in "y" after processing backspaces.
grad Sample Case 1
Sample Input For Custom Testing
hacellkkil
hblliackkH
Sample Output
Explanation
The first string becomes "hack" while the second string becomes "ac".Complete the 'comparestrings' function below.The function is expected to return an InTEGER.The function accepts following parameters:STRING s 1STRING 52*1public static int comparestrings(5tring s1, String s2){String processeds1- processstring (51);strting processeds2- processstring (52);
return processeds1.equals(processeds2)?1:0;
1
pubtic class solution ti-
Language Java 1 5 Invironment Question 1 4 Two

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!