subject

Write a function called backspaceCompare that takes two strings sl and s2 and evaluate them when both are typed into empty text editors. (# means a backspace character). backspacecompare should return true if the evaluated strings are equal or false if they are not equal. You should make use of the built-in java implementation of the stack data structure under java. util. Stack . (assume that the user inputs correct strings)
Example 1:
Input : s1 = "Datastructure si###Fun", s2 = "Datastructures Iszwp###Fun"
Output: true
Explanation: Both s1 and s2 become "DataStructuresIsFun".
Example 2:
Input : S = "abc##, T = "wc#d#"
Output: false
Explanation: s1 becomes "a" while s2 becomes "w"
Function Template
import java. util. Stack;
public class Lab3 {
public static void main (String[] args) {
String s1 = "Dat astructure si###Fun";
String s2 = "Dat astructure s1szwp###Fun";
boolean ans = backspaceCompare(s1, s2);
System. out. println (ans); // Should be True
}
public static boolean backspaceCompare(String s1, String s2) {
Stack s1 stack = new Stack();
Stack s2 stack = new Stack();
// Example of push stack. push("D")
// Example of peek stack. peek()
// Example of pop stack. pop()
// Example of İsEmpty stack. isEmpty()
// INSERT YOUR CODE HERE
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Which action is good business etiquette? a. switching your cell phone off before you enter a meeting b. keeping your cell phone on low volume before you enter a meeting c. setting a pleasant ring tone on your cell phone before you enter a meeting d. setting a standard ringtone on your cell phone before you enter a meeting
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
You know the right answer?
Write a function called backspaceCompare that takes two strings sl and s2 and evaluate them when bot...
Questions