Answered step by step
Verified Expert Solution
Link Copied!

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 INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY pref as parameter.
*/
public static List getOriginalArray(List pref){
// Write your code here
}
}
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")));
int prefCount = Integer.parseInt(bufferedReader.readLine().trim());
List pref = IntStream.range(0, prefCount).mapToObj(i ->{
try {
return bufferedReader.readLine().replaceAll("\\s+$","");
} catch (IOException ex){
throw new RuntimeException(ex);
}
})
.map(String::trim)
.map(Integer::parseInt)
.collect(toList());
List result = Result.getOriginalArray(pref);
bufferedWriter.write(
result.stream()
.map(Object::toString)
.collect(joining("
"))
+"
"
);
bufferedReader.close();
bufferedWriter.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

There is no arbitrage if and only if there exist state prices.

Answered: 1 week ago