Computers and Technology

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
}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, Boogates7427
Apower user needs you to install a second type of operating system on his computer to increase efficiency while running some specialized software programs. which installation technique should you use?
Answers: 3
image
Computers and Technology, 22.06.2019 09:00, starwarsfan1975
Meenu wants to create a high quality drawing in a variety of colours. which device should she use for the same?
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, tfornwalt4390
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
image
Computers and Technology, 23.06.2019 18:50, ana7496
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
Do you know the correct answer?
Write a function called backspaceCompare that takes two strings sl and s2 and evaluate them when bot...

Questions in other subjects:

Konu
English, 30.11.2019 23:31