Problem:- Write a Hackerrank Solution For Day 11: 2D Arrays or Hacker Rank Solution Program In C++ For ” Day 11: 2D Arrays ” or Hackerrank 30 days of code Java Solution:Day 11: 2D Arrays solution or Hackerrank solution for 30 Days of Code Challenges or Hackerrank 30 days of code Java Solution, Day 11: 2D Arrays solution, or C/C++ Logic & Problem Solving: Day 11: 2D Arrays.
Logic:- So basically the problem is clear we have to find hourglass sum or maximum hourglass sum in a given 2D array. Hourglass is a sum of input in a 2D array those shapes are in ‘A’ graphical. We can understand this by taking an example of a 2D array. Below are an example and solution to this problem.
Before solving this problem let’s first know What is Array? An array is a group of similar data types.
So basically we have to find the maximum sum of A shapes in a Matrix.
2D Arrays HackerRank solution in Python :
arr =  for _ in range(6): tmp = [int(x) for x in str(input()).split(" ")] arr.append(tmp) maximum = -9 * 7 for i in range(6): for j in range(6): if j + 2 < 6 and i + 2 < 6: result = 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 result > maximum: maximum = result print(maximum)
Tip:- Always try to implement the own logic this will help you to solve and building logic. Before copy the program I recommended please read this full article, this will help you to build your own logic.