Skip to content

chips03/hourglass-problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Hourglass Problem

Solution for hourglass problem in 2D Array

The problem

Given a 2D matrix, the task is to find the maximum sum of an hourglass.

An hour glass is made of 7 cells
in following form.
    A B C
      D
    E F G

Examples

Input : 1 1 1 0 0 
        0 1 0 0 0 
        1 1 1 0 0 
        0 0 0 0 0 
        0 0 0 0 0 
Output : 7
Below is the hour glass with
maximum sum:
1 1 1 
  1
1 1 1
                                                      
Input : 0 3 0 0 0
        0 1 0 0 0
        1 1 1 0 0
        0 0 2 4 4
        0 0 0 2 4
Output : 11
Below is the hour glass with
maximum sum
1 0 0
  4
0 2 4

Requirement

JDK 17 LTS

About

Solution for hourglass problem in 2D Array

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages