Question: Please help me with this Java question. We are given a code to work with and please use Java 8 to answer the question. Here

Please help me with this Java question. We are given a code to work with and please use Java 8 to answer the question.

Please help me with this Java question. We are given a code

to work with and please use Java 8 to answer the question.

Here is a code we are given to work with.

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;

public class Solution {

public static void main(String[] args) throws IOException {

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

List> arr = new ArrayList();

IntStream.range(0, 6).forEach(i -> {

try {

arr.add(

Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))

.map(Integer::parseInt)

.collect(toList())

);

} catch (IOException ex) {

throw new RuntimeException(ex);

}

});

bufferedReader.close();

}

}

You are given a 66 2D array. An hourglass in an array is a portion shaped like this: dabcefg For example, if we create an hourglass using the number 1 within an array full of zeros, it may look like this: 101000111000101000000000000000000000 Actually, there are many hourglasses in the array above. The three leftmost hourglasses are the following: The sum of an hourglass is the sum of all the numbers within it. The sum for the hourglasses above are 7, 4, and 2, respectively. In this problem you have to print the largest sum among all the hourglasses in the array. Input Format There will be exactly 6 lines, each containing 6 integers seperated by spaces. Each integer will be between -9 and 9 inclusive. Output Format Print the answer to this problem on a single line

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!