Question: Write a function called backspaceCompare that takes two strings si and s2 and evaluate them when both are typed into empty text editors. (# means

 Write a function called backspaceCompare that takes two strings si and

Write a function called backspaceCompare that takes two strings si 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 - "DataStructures Issss###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 "awhile s2 becomes "w" --Function Template import java.util.Stack; public class Lab3 { public static void main (String[] args) { String s1 = "DataStructuresIssss###Fun"; String 52 = "DataStructuresIszwp###Fun"; boolean ans = backspaceCompare(s1, s2); System.out.println(ans); // Should be True } public static boolean backspaceCompare(String si, String s2){ Stack si stack new Stack(); StackCharacter> s2 stack = new Stack(); // Example of push stack.push("D") // Example of peek stack.peek) // Example of pop stack.pop() // Example of isEmpty stack.isEmpty() // INSERT YOUR CODE HERE } }

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 Databases Questions!