You are viewing a single comment's thread. Return to all comments →
[Java]
Depois de muita tentativa e erro consegui fazer o exercicio desta forma
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<List<Integer>> arr = new ArrayList<>(); int maxSum = Integer.MIN_VALUE; 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); } }); for (int indexI = 0; indexI <= arr.size() - 3; indexI++) { for(int indexJ = 0; indexJ <= arr.get(indexI).size() - 3; indexJ++){ int hourglassSum = arr.get(indexI).get(indexJ) + arr.get(indexI).get(indexJ + 1) + arr.get(indexI).get(indexJ + 2) + arr.get(indexI + 1).get(indexJ + 1) + arr.get(indexI + 2).get(indexJ) + arr.get(indexI + 2).get(indexJ + 1) + arr.get(indexI + 2).get(indexJ + 2); if (hourglassSum > maxSum) { maxSum = hourglassSum; } } } System.out.println(maxSum); undefined
O maior problema era identificar como fazer a leitura do relógio
bufferedReader.close(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
[Java]
Depois de muita tentativa e erro consegui fazer o exercicio desta forma
O maior problema era identificar como fazer a leitura do relógio
}