Java concise and efficient solution; explanation included
\nclass Solution {\n    \n    public int maxTrailingZeros(int[][] grid) {\n        \n        int rows = grid.length;\n        int cols = grid[0].length;\n      
```\nclass Solution {\n    \n    public int maxTrailingZeros(int[][] grid) {\n        \n        int rows = grid.length;\n        int cols = grid[0].length;\n        \n        // twoAndFives[i][j][0] is the number of factor 2 of grid[i][j]\n        // twoAndFives[i][j][1] is the number of factor 5 of grid[i][j]\n        int[][][] twoAndFives = new int[rows][cols][2];\n        \n        for (int i = 0; i < rows; i++) {\n            for (int j = 0; j < cols; j++) {\n                int num = grid[i][j];\n                int twos = 0;\n                int fives = 0;\n                while (num % 2 == 0) {\n                    num /= 2;\n                    twos++;\n                }\n                while (num % 5 == 0) {\n                    num /= 5;\n                    fives++;\n                }\n                twoAndFives[i][j] = new int[] {twos, fives};\n            }\n        }\n        \n        int[][] prefixRowTwo  = new int[rows][cols+1];\n        int[][] prefixRowFive = new int[rows][cols+1];\n        \n        int[][] prefixColTwo  = new int[cols][rows+1];\n        int[][] prefixColFive = new int[cols][rows+1];\n\n        for (int i = 0; i < rows; i++) {\n            for (int j = 0; j < cols; j++) {\n                prefixRowTwo[i][j+1]  = prefixRowTwo[i][j]  + twoAndFives[i][j][0];\n                prefixRowFive[i][j+1] = prefixRowFive[i][j] + twoAndFives[i][j][1];\n            }\n        }\n        \n        for (int j = 0; j < cols; j++) {\n            for (int i = 0; i < rows; i++) {\n                prefixColTwo[j][i+1]  = prefixColTwo[j][i]  + twoAndFives[i][j][0];\n                prefixColFive[j][i+1] = prefixColFive[j][i] + twoAndFives[i][j][1];\n            }\n        }\n        \n        int max = 0;\n        for (int i = 1; i <= rows; i++) {\n            for (int j = 1; j <= cols; j++) {\n                \n                // Path: top-down then turn left\n                max = Math.max(max, Math.min(prefixRowTwo[i-1][j] + prefixColTwo[j-1][i-1], prefixRowFive[i-1][j] + prefixColFive[j-1][i-1]));\n                \n                // Path: bottom-up then turn left\n                max = Math.max(max, Math.min(prefixRowTwo[i-1][j] + prefixColTwo[j-1][rows] - prefixColTwo[j-1][i], prefixRowFive[i-1][j] + prefixColFive[j-1][rows] - prefixColFive[j-1][i]));\n                \n                // Path: top-down then turn right\n                max = Math.max(max, Math.min(prefixRowTwo[i-1][cols] - prefixRowTwo[i-1][j] + prefixColTwo[j-1][i], prefixRowFive[i-1][cols] - prefixRowFive[i-1][j] + prefixColFive[j-1][i]));\n                \n                // Path: bottom-up then turn right\n                max = Math.max(max, Math.min(prefixRowTwo[i-1][cols] - prefixRowTwo[i-1][j] + prefixColTwo[j-1][rows] - prefixColTwo[j-1][i-1], prefixRowFive[i-1][cols] -prefixRowFive[i-1][j] + prefixColFive[j-1][rows] - prefixColFive[j-1][i-1]));\n            }\n        }\n\n        return max;\n    }\n}\n```
[]