forked from sknsht/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.java
31 lines (26 loc) · 850 Bytes
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] a = new int[6][6];
int max = Integer.MIN_VALUE;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
a[i][j] = sc.nextInt();
if (i > 1 && j > 1) {
int sum = a[i][j]
+ a[i][j - 1]
+ a[i][j - 2]
+ a[i - 1][j - 1]
+ a[i - 2][j]
+ a[i - 2][j - 1]
+ a[i - 2][j - 2];
if (sum > max)
max = sum;
}
}
}
sc.close();
System.out.println(max);
}
}