C++ || PREFIX SUM || COUNT 2'S AND 5'S || FASTER THAN 100%
\nclass Solution {\npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int m=grid.size(),n=grid[0].size();\n        int res=0;\n        vec
```\nclass Solution {\npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int m=grid.size(),n=grid[0].size();\n        int res=0;\n        vector<vector<int>> v1(m,vector<int>(n,0)),v2(m,vector<int>(n,0));\n        vector<vector<int>> v3(m,vector<int>(n,0)),v4(m,vector<int>(n,0));\n        for(int i=0;i<m;i++){\n            int cnt=0;\n            int twos=0,fives=0;\n            for(int j=0;j<n;j++){\n                int temp=grid[i][j];\n                int cnt1=0,cnt2=0;\n                while(temp>0 and temp%2==0){\n                    cnt1++;\n                    temp/=2;\n                } \n                temp=grid[i][j];\n                while(temp>0 and temp%5==0){\n                    cnt2++;\n                    temp/=5;\n                }\n                twos+=cnt1;\n                fives+=cnt2;\n                v1[i][j]=twos;\n                v2[i][j]=fives;\n            }\n        }\n        for(int i=0;i<n;i++){\n            int cnt=0;\n            int twos=0,fives=0;\n            for(int j=0;j<m;j++){\n                int temp=grid[j][i];\n                int cnt1=0,cnt2=0;\n                while(temp>0 and temp%2==0){\n                    cnt1++;\n                    temp/=2;\n                } \n                temp=grid[j][i];\n                while(temp>0 and temp%5==0){\n                    cnt2++;\n                    temp/=5;\n                }\n                twos+=cnt1;\n                fives+=cnt2;\n                v3[j][i]=twos;\n                v4[j][i]=fives;\n            }\n        }\n        \n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                int curr=0;\n                int twos=v1[i][j],fives=v2[i][j];\n                int cnt1=0,cnt2=0;\n                int temp=grid[i][j];\n                while(temp>0 and temp%2==0){\n                    temp/=2;\n                    cnt1++;\n                }\n                \n                temp=grid[i][j];\n                while(temp>0 and temp%5==0){\n                    temp/=5;\n                    cnt2++;\n                }\n                \n                res=max(res,min(twos+v3[m-1][j]-v3[i][j],fives+v4[m-1][j]-v4[i][j]));\n                res=max(res,min(twos+v3[i][j]-cnt1,fives+v4[i][j]-cnt2));\n                res=max(res,min(v1[i][n-1]-twos+v3[i][j],v2[i][n-1]-fives+v4[i][j]));\n                res=max(res,min(v1[i][n-1]-twos+v3[m-1][j]-v3[i][j]+cnt1,v2[i][n-1]-fives+v4[m-1][j]-v4[i][j]+cnt2));\n            }\n        }\n        return res;\n    }\n};\n```
['C', 'Prefix Sum']