C++ || EXPLANATION || EASY ||
We can then treat each cell as the elbow point and calculate the largest minimum (sum of 2 exponents, sum of 5 exponents) from the combination of top-left, top-
**We can then treat each cell as the elbow point and calculate the largest minimum (sum of 2 exponents, sum of 5 exponents) from the combination of top-left, top-right, bottom-left and bottom-right.**\n\n```\nclass Solution {\npublic:\n    int pow2(int num)\n    {   int cnt=0;\n        while(num%2==0)\n        {\n            cnt=cnt+1;\n            num=num/2;\n        }\n     return cnt;\n    }\n    \n    int pow5(int num)\n    {   int cnt=0;\n        while(num%5==0)\n        {\n            cnt=cnt+1;\n            num=num/5;\n        }\n     return cnt;\n    }\n    \n    int ans=0;\n    \n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        \n    vector<pair<int, int>> up (grid[0].size(), std::make_pair(0,0));\n    vector<pair<int, int>> dwn (grid[0].size(), std::make_pair(0,0));\n    vector<pair<int, int>> rht (grid.size(), std::make_pair(0,0));\n    vector<pair<int, int>> lft (grid.size(), std::make_pair(0,0));\n         \n         for(int i=0;i<grid.size();i=i+1)\n        {   \n             int a=0;\n             int b=0;\n             for(int j=grid[0].size()-1;j>=0;j=j-1)\n            {\n                a=a+pow2(grid[i][j]);\n                b=b+pow5(grid[i][j]);\n            }\n             rht[i].first=a;\n             rht[i].second=b;\n             ans=max(ans,min(a,b));\n         }\n        \n         for(int i=0;i<grid[0].size();i=i+1)\n        {   \n             int a=0;\n             int b=0;\n             for(int j=grid.size()-1;j>=0;j=j-1)\n            {\n                a=a+pow2(grid[j][i]);\n                b=b+pow5(grid[j][i]);\n            }\n             dwn[i].first=a;\n             dwn[i].second=b; \n              ans=max(ans,min(a,b));\n         }\n        \n       \n        for(int i=0;i<grid.size();i=i+1)\n        {\n            for(int j=0;j<grid[0].size();j=j+1)\n            {\n                \n                int a=pow2(grid[i][j]);\n                int b=pow5(grid[i][j]);\n                rht[i].first=rht[i].first-a;\n                rht[i].second=rht[i].second-b;\n                dwn[j].first=dwn[j].first-a;\n                dwn[j].second=dwn[j].second-b;\n                \n                ans=max(ans,min(rht[i].first+dwn[j].first+a,rht[i].second+dwn[j].second+b));\n                ans=max(ans,min(rht[i].first+up[j].first+a,rht[i].second+up[j].second+b));\n                ans=max(ans,min(lft[i].first+dwn[j].first+a,lft[i].second+dwn[j].second+b));\n                ans=max(ans,min(lft[i].first+up[j].first+a,lft[i].second+up[j].second+b));\n                \n               lft[i].first=lft[i].first+a;\n               lft[i].second=lft[i].second+b; \n               up[j].first=up[j].first+a;\n               up[j].second=up[j].second+b;\n            }\n        }\n        return ans;\n    }\n};\n```\n\n**If you found it helpful, kindly upvote!!!**
[]