We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 99cf989 commit dcad017Copy full SHA for dcad017
Arrays/(HACKERRANK)Hourglass_Subset.java
@@ -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
28
29
30
31
+ System.out.println(sum);
32
33
+}
0 commit comments