C++, stl solution, easy to understand, beats 93% time & space, O(mn) time, O(m+n) space
Intuition\n Describe your first thoughts on how to solve this problem. \nOn the surface the problem is pretty similar to prefix sum. If you have time, I highly 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOn the surface the problem is pretty similar to prefix sum. If you have time, I highly recommend checking prefix sum before. Check the hints if you need help. This is a 2D version of prefix sum.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we calculate the sum of 2-factors & 5-factors row-wise & column-wise in 1st pass. Then we go through the array again, however, we now know the totals for every row & col, we can subtract the sum upto the curr_value to get the factors of the remaining part of the column (right side) & bottom part. As shown below\n\n```\n                ------\u25B2------      row totals (rv)\n                |      |up    |       2, 1\n                |<-----e----->|       0, 2\n                | left |right |       .\n                |      |      |       .\n                |      |      |       .\n                |      |down  |\n                ------\u25BC------\ncol totals(cv)  2,3  1,0 .....\n```\n\nWe then add up the totals for all combinations taking the curr element as pivot, thus we can have,\n- left + up\n- up + right\n- left + down\n- down + right\n\nWe must take care to make sure that the current element is included only once in each of these computations. Once we have the intermediate totals, we calculate zeros as min(2-factors, 5-factors), then we compute the maximum of all 4 possible combinations.\n\nLastly, update the counts & add the current values to running totals. Note, we use a vector to keep track of current row.\n\n# Complexity\n- Time complexity: $$O(m * n)$$ for 2 traversals \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: $$O(m + n)$$ where m,n = rows, cols\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n// Save some typing :)\n// tuple <int,int> = factors of 2,5\nusing tup2 = tuple<int,int>;\nusing vtup2 = vector<tup2>;\n\n// Return min value of a tuple\ninline int tup2_min(tup2 &a) {\n    return min(get<0>(a), get<1>(a));\n}\n\n// Its handy to have these for adding and subtracting\n// the number of factors\ntup2 operator + (tup2 &a, tup2 b) {\n    return tup2(get<0>(a) + get<0>(b), \n                get<1>(a) + get<1>(b));\n}\n\ntup2 operator - (tup2 &a, tup2 b) {\n    return tup2(get<0>(a) - get<0>(b), \n                get<1>(a) - get<1>(b));\n}\n\n// basic prime factorization algo\ntup2 pfact2_5 (int t) {\n    int f2 = 0, f5 = 0;\n\n    while (t % 2 == 0 || t % 5 == 0) {\n        if (t % 5 == 0) {\n            f5++;\n            t /= 5;\n        } else if (t % 2 == 0) {\n            f2++;\n            t /= 2;\n        }\n    }\n\n    return tup2({f2, f5});\n}\n\nclass Solution {\npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int rows = grid.size(), cols = grid[0].size();\n        vtup2 rv(rows, {0,0});\n        vtup2 cv(cols, {0,0});\n\n        // add up all the factors row-wise\n        // and column-wise \n        for (int i = 0; i < rows; i++) {\n            tup2 f = {0, 0};\n            for (int j = 0; j < cols; j++) {\n                tup2 tf = pfact2_5(grid[i][j]);\n                f = f + tf;\n\n                cv[j] = cv[j] + tf;\n            }\n            rv[i] = rv[i] + f;\n        }\n    \n\n        // maintain current row status\n        int max_zeros = 0;\n        vtup2 row_ctr(cols, {0,0});\n\n        // choose each i, j as elbow points\n        for (int i = 0; i < rows; i++) {\n            tup2 cf = {0,0};\n            for (int j = 0; j < cols; j++) {\n                tup2 tf = pfact2_5(grid[i][j]);\n\n                tup2 left = cf;\n                tup2 right = rv[i] - left;\n\n                tup2 up = row_ctr[j];\n                tup2 down = cv[j] - up;\n\n                // Note:\n                // be careful to add the element factors only once\n                // subtract where we added twice\n                // rule of thumb: left & up does not have\n                // the current element included while down & right does\n                tup2 tl = up + left;    tl = tl + tf;\n                tup2 tr = up + right;\n                tup2 bl = down + left;\n                tup2 br = down + right; br = br - tf;\n\n                // store temporarily to calculate max element\n                int mx[] = {tup2_min(tl), tup2_min(tr), tup2_min(bl), tup2_min(br)};\n\n                // update max_zeros\n                max_zeros = max(*max_element(begin(mx), end(mx)), max_zeros);\n\n                // update running row counts and column\n                cf = cf + tf;\n                row_ctr[j] = row_ctr[j] + tf;\n            }\n        }\n\n        return max_zeros;\n    }\n};\n```
['C++']