Java or C# preferred. import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Java or C# preferred. import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util

Post by answerhappygod »

Java Or C Preferred Import Java Io Import Java Math Import Java Security Import Java Text Import Java Util 1
Java Or C Preferred Import Java Io Import Java Math Import Java Security Import Java Text Import Java Util 1 (153.89 KiB) Viewed 50 times
Java or C# preferred.
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
class Result {
/*
* Complete the 'compareStrings' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. STRING s1
* 2. STRING s2
*/
public static int compareStrings(String s1, String s2) {
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String s1 = bufferedReader.readLine();
String s2 = bufferedReader.readLine();
int result = Result.compareStrings(s1, s2);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
bufferedReader.close();
bufferedWriter.close();
}
}
Info Java 15(Recommended) Autocomplete Ready O BETA Can't read the text? Switch theme 1. Backspace String Compare 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 o if they are not. Note that backspacing an empty string results in an empty string. i > import java.io.*; --- 14 15 class Result { 16 17 18 * Complete the 'compareStrings' function below. 19 20 * The function is expected to return an INTEGER. 21 * The function accepts following parameters: 22 * 1. STRING Sl 23 * 2. STRING s2 24 * 25 26 public static int compareStrings (String si, String, s2) { 27 28 } 29 30 ] } 31 32 > public class Solution { Example s1 = 'axx#bb#c' s2 = 'axbd#C#C In the first string one 'x' and one 'b' are backspaced over. The first string becomes axbc. The second 1 string also becomes axbc. The answer is 1. Function Description Complete the function compareStrings in the editor below. compare Strings has the following parameter(s): string st: the first string string 52: the second string Returns int: either 0 or 1 : Constraints • 15 length of s1 s2*105 • 18 length of 52 52*105 • Both s1 and 2 contain lowercase English letters and/or the character"#" only. Input Format For Custom Testing Sample Case o Sample Input For Custom Testing yf#c# yywkipp## Sample Output i Explanation Both the strings 51 and 52 result in "y" after processing backspaces. Sample Case 1
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply