Skip to content

Commit dcad017

Browse files
Create (HACKERRANK)Hourglass_Subset.java
1 parent 99cf989 commit dcad017

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.util.*;
2+
public class Solution
3+
{
4+
public static void main(String [] args)
5+
{
6+
Scanner sc = new Scanner (System.in);
7+
8+
int arr[][]=new int [6][6];
9+
10+
for(int i=0;i<6;i++)
11+
{
12+
for(int j=0;j<6;j++)
13+
arr[i][j]=sc.nextInt();
14+
}
15+
16+
int sum=0;
17+
18+
for(int i=0;i<4;i++)
19+
{
20+
for(int j=0;j<4;j++)
21+
{
22+
int temp=arr[i][j]+arr[i][j+1]+arr[i][j+2]+arr[i+1][j+1]+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2];
23+
24+
if(i==0 && j==0)
25+
sum=temp;
26+
else if(temp>sum)
27+
sum=temp;
28+
}
29+
}
30+
31+
System.out.println(sum);
32+
}
33+
}

0 commit comments

Comments
 (0)