c++ || 100% fast, easy approach
calculate powers of 2 and 5 in factors of each grid[i][j] item in a vectorof pairs of int \n2. make 2 matrices v and h, v stores vertical prefix sum (for each c
1. calculate powers of 2 and 5 in factors of each grid[i][j] item in a vectorof pairs of int \n2. make 2 matrices v and h, v stores vertical prefix sum (for each column seprately)of values of fac and h stores horizontal prefix sum (for each row).\n3. now in nother loop calculate ans using h and v\n```\n#define fo(i,s,e) for(int i=s;i<=e;i++)\npair<int,int> operator+(pair<int,int>a,pair<int,int>b){\n      return make_pair(a.first+b.first,a.second+b.second);\n  }  \npair<int,int> operator-(pair<int,int>a,pair<int,int>b){\n      return make_pair(a.first-b.first,a.second-b.second);\n  }  \nint mx(pair<int,int>a){\n      return min(a.first,a.second);\n}\nclass Solution {\n    pair<int,int>fact25(int val){\n        int cnt=0,cnt2=0;\n        while(val!=0&&val%2==0)\n        {cnt++;val/=2;}\n        \n        while(val!=0&&val%5==0){\n            cnt2++;val/=5;\n        }\n        return make_pair(cnt,cnt2);\n    }\n    \npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int m=grid.size();\n        int n=grid[0].size();\n        vector<vector<pair<int,int>>>fac(m+1,vector<pair<int,int>>(n+1,make_pair(0,0))),h,v;\n        v=h=fac;\n        fac.clear();\n        fo(i,1,m){\n            fo(j,1,n){\n                auto x=fact25(grid[i-1][j-1]);\n                v[i][j]=v[i-1][j]+x;\n                h[i][j]=h[i][j-1]+x;\n            }\n        }\n        \n        int ans=0;\n        fo(i,1,m){\n            fo(j,1,n){\n                pair<int,int> hl,hr,vu,vd;\n                hl=h[i][j];\n                hr=h[i][n]-h[i][j-1];\n                vu=v[i-1][j];\n                vd=v[m][j]-v[i][j];\n                ans=max({ans,mx(vu+hl),mx(vu+hr),mx(vd+hl),mx(vd+hr)});\n            }\n        } \n        return ans;\n    }\n};\n```
['C']