Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.io . * ; import java.math. * ; import java.security. * ; import java.text. * ; import java.util. * ; import java.util.concurrent. * ;
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 'getOriginalArray' function below.
The function is expected to return an INTEGERARRAY.
The function accepts INTEGERARRAY pref as parameter.
public static List getOriginalArrayList pref
Write your code here
public class Solution
public static void mainString args throws IOException
BufferedReader bufferedReader new BufferedReadernew InputStreamReaderSystemin;
BufferedWriter bufferedWriter new BufferedWriternew FileWriterSystemgetenvOUTPUTPATH";
int prefCount Integer.parseIntbufferedReaderreadLinetrim;
List pref IntStream.range prefCountmapToObji
try
return bufferedReader.readLinereplaceAlls$;
catch IOException ex
throw new RuntimeExceptionex;
mapString::trim
mapInteger::parseInt
collecttoList;
List result Result.getOriginalArraypref;
bufferedWriter.write
result.stream
mapObject::toString
collectjoining
;
bufferedReader.close;
bufferedWriter.close;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started