• + 0 comments

    In C#

    public static int SearchArray(List<List<int>> arr)
    {
        int maxY = arr.Count - 1;
        int maxX = arr[0].Count - 1;
          
        int maxCount = -63;
            
        for(int curY = 1; curY < maxY; curY++)
        {
            for(int curX = 1; curX < maxX; curX++)
            {
                int curCount = arr[curY-1].GetRange(curX-1, 3).Sum();
                curCount += arr[curY][curX];
                curCount += arr[curY+1].GetRange(curX-1, 3).Sum();
                
                maxCount = curCount > maxCount ? curCount : maxCount;
            }
        }
        
        return maxCount;
    }