JavaScript Solution
\nvar maxTrailingZeros = function(grid) {\n    const m = grid.length;\n    const n = grid[0].length;\n    \n    const postfixCols = [];\n    \n    for (let i = 
```\nvar maxTrailingZeros = function(grid) {\n    const m = grid.length;\n    const n = grid[0].length;\n    \n    const postfixCols = [];\n    \n    for (let i = 0; i < m; ++i) {\n        for (let j = 0; j < n; ++j) {\n            const num = grid[i][j];\n            \n            if (postfixCols[j] == null) postfixCols[j] = { 2: 0, 5: 0 };\n            \n            postfixCols[j]["2"] += getCount(num, 2);\n            postfixCols[j]["5"] += getCount(num, 5);\n        }\n    }\n    \n    const prefixCols = [];\n    \n    for (let j = 0; j < n; ++j) {\n        prefixCols[j] = { 0: 0, 2: 0, 5: 0 }; \n    }\n    \n    let maxZeros = 0;\n    \n    for (let i = 0; i < m; ++i) {\n        const postfixRow = { 0: 0, 2: 0, 5: 0 };\n        \n        for (let j = n - 1; j >= 0; --j) {\n            const num = grid[i][j];\n            \n            postfixRow["2"] += getCount(num, 2);\n            postfixRow["5"] += getCount(num, 5);\n        }\n        \n        let prefixRow = { 0: 0, 2: 0, 5: 0 };\n        \n        for (let j = 0; j < n; ++j) {\n            const num = grid[i][j];\n\n            const twoCount = getCount(num, 2);\n            const fiveCount = getCount(num, 5);\n\n            postfixRow["2"] -= twoCount;\n            postfixCols[j]["2"] -= twoCount;\n\n            postfixRow["5"] -= fiveCount;\n            postfixCols[j]["5"] -= fiveCount;\n\n            // down-right => prefixCol + postfixRow\n            const downRight = calculateTrailingZeros(prefixCols[j], postfixRow, num);\n            // down-left => prefixCol + prefixRow\n            const downLeft = calculateTrailingZeros(prefixCols[j], prefixRow, num);\n            // up-right => postfixCols + postfixRow\n            const upRight = calculateTrailingZeros(postfixCols[j], postfixRow, num);\n            // up-left => postfixCols + prefixRow\n            const upLeft = calculateTrailingZeros(postfixCols[j], prefixRow, num);\n            \n            maxZeros = Math.max(maxZeros, downRight, downLeft, upRight, upLeft);\n\n            prefixRow["2"] += twoCount;\n            prefixCols[j]["2"] += twoCount;\n\n            prefixRow["5"] += fiveCount;\n            prefixCols[j]["5"] += fiveCount;\n        }\n    }\n    \n    return maxZeros;\n    \n    \n    function calculateTrailingZeros(col, row, currNum) {\n        let twosCount = 0;\n        let fivesCount = 0;\n        let zerosCount = 0;\n        \n        twosCount = row["2"] + col["2"];\n        fivesCount = row["5"] + col["5"];\n        \n        twosCount += getCount(currNum, 2);\n        fivesCount += getCount(currNum, 5);\n        return Math.min(twosCount, fivesCount);\n    }\n    \n    function getCount(num, divisor) {\n        let count = 0;\n        \n        while (num % divisor === 0) {\n            ++count;\n            num /= divisor;\n        }\n        \n        return count;\n    } \n};\n```
['JavaScript']