[Python]The time limit for python is merciless 😢
I use 3 different way to implement the O(M*N) algorithm because of TLE result.\nlost more than 40 minutes here. \uD83D\uDE22\n\nclass Solution:                 
I use 3 different way to implement the O(M*N) algorithm because of TLE result.\nlost more than 40 minutes here. \uD83D\uDE22\n```\nclass Solution:                                                                                                 \n    def maxTrailingZeros(self, grid):                                                                           \n                                                                                                    \n        def get25(n):                                                                                           \n            c2,c5 = 0,0                                                                                 \n            while n and n % 2 == 0:                                                                             \n                c2 += 1                                                                                 \n                n = n // 2                                                                                      \n            while n and n % 5 == 0:                                                                             \n                c5 += 1                                                                                 \n                n = n // 5                                                                                      \n            return [c2,c5] \n        c25 = []\n        for i in range(1001):\n            c25.append(get25(i))\n                                                                                                                \n        m, n = len(grid), len(grid[0])                                                                          \n        grid = list(map(lambda x: list(map(lambda xx: c25[xx][:], x)), grid))                          \n        l = [[[0,0] for _ in range(n)] for _ in range(m)]                                                   \n        r = [[[0,0] for _ in range(n)] for _ in range(m)]                                                 \n        u = [[[0,0] for _ in range(n)] for _ in range(m)]                                                \n        b = [[[0,0] for _ in range(n)] for _ in range(m)]                                                 \n        for i in range(m):                                                                                      \n            for j in range(0, n):\n                for k in range(2):\n                    l[i][j][k] = grid[i][j][k]\n                    u[i][j][k] = grid[i][j][k]\n                    if j != 0:                                                                                      \n                        l[i][j][k] += l[i][j - 1][k]                                                       \n                    if i != 0:                                                                                      \n                        u[i][j][k] += u[i - 1][j][k]                                                    \n        ans = 0                                                                                                 \n        for i in range(m - 1, -1, -1):                                                                          \n            for j in range(n - 1, -1, -1):\n                q1,q2,q3,q4 = 10**10,10**10,10**10,10**10\n                for k in range(2):\n                    b[i][j][k] = grid[i][j][k]\n                    r[i][j][k] = grid[i][j][k]  \n                    if i != m - 1:                                                                                  \n                        b[i][j][k] += b[i + 1][j][k]                                                       \n                    if j != n - 1:                                                                                  \n                        r[i][j][k] += r[i][j + 1][k]\n                    q1 = min(q1,r[i][j][k]+u[i][j][k]-grid[i][j][k])\n                    q2 = min(q2,r[i][j][k]+b[i][j][k]-grid[i][j][k])\n                    q3 = min(q3,l[i][j][k]+u[i][j][k]-grid[i][j][k])\n                    q4 = min(q4,l[i][j][k]+b[i][j][k]-grid[i][j][k])                                                           \n                ans = max(ans,q1,q2,q3,q4)      \n                                                                                                                \n        return ans     \n```
[]