Input Format
There are  lines of input, where each line contains  space-separated integers describing 2D Array ; every value in  will be in the inclusive range of  to .
Output Format
Print the largest (maximum) hourglass sum found in A.
2D Array problem solution - 30 days of code HackerRank

Problem solution in Java programming language.

import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.math.*;
 import java.util.regex.*;

 public class Solution {

     public static void main(String[] args) {
         Scanner in = new Scanner(System.in);
         int arr[][] = new int[6][6];
         for(int i=0; i < 6; i++){
             for(int j=0; j < 6; j++){
                 arr[i][j] = in.nextInt();
             }
         }
         int sum = -10000;
         for (int i = 0; i < 4; i++) {
             for (int j = 0; j < 4; j++) {
                
                 // [00] [01] [02]
                 //      [11]
                 // [20] [21] [22]
               
                 int currentSum = 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];
                 if (currentSum > sum) {
                     sum = currentSum;
                 }
             }
         }
        
         System.out.println(sum);
     }
 }

Problem solution in Python programming language.

#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    arr = []

    for _ in range(6):
        arr.append(list(map(intinput().rstrip().split())))
    sum = 0
    tarr = []
    
    for l in range(0,4):
        for k in range(0,4):
            for i in range(l,l+3):
                for j in range(k,k+3):
                    if i == l+1 and ( j == k or j == k+2):
                        continue
                    else:
                        sum += arr[i][j]
            tarr.append(sum)
            sum = 0
    
    print(max(tarr))