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, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Why do we mark tlc plates with pencil and not with pen
Answers: 2
question
Computers and Technology, 24.06.2019 10:10
Scanning the road can be thought of as a
Answers: 2
question
Computers and Technology, 24.06.2019 17:30
When you type january in a cell, then copy it using the fill handle to the cells below and the data automatically changes to february, march, april, and so on, what is this feature called? auto fill automaticcopy monthfill textfill
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
Questions on the website: 13722360