• + 1 comment

    For each hourglass, you are finding the sum. There are 16 sums you are finding. max needs to be whichever sum is the largest. So, inside your double for loop right when you calculate sum, you need to update max if you have found a sum that's bigger than your previous max, as so:

    max = Math.max(max, sum);
    

    HackerRank solutions.