prefix and suff
class Solution {\npublic:\n\n\n    int maxTrailingZeros(vector>& grid) {\n         \n      vector>> pref = vector(grid.size(),vector>(grid[0].size()));\n      v
class Solution {\npublic:\n\n\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n         \n      vector<vector<pair<int,int>>> pref = vector(grid.size(),vector<pair<int,int>>(grid[0].size()));\n      vector<vector<pair<int,int>>> suff = vector(grid.size(),vector<pair<int,int>>(grid[0].size()));\n      \n      \n      for(int i=0;i<grid.size();i++)\n      {\n        for(int j=0;j<grid[0].size();j++)\n        {\n           int two=0,five=0;\n           int x = grid[i][j];\n          while(x%2 == 0) two++, x=x/2;\n          while(x%5 == 0) five++,x=x/5;\n          pref[i][j] = {two,five};\n          if(j!=0)\n          {\n            pref[i][j] = {pref[i][j].first+pref[i][j-1].first,pref[i][j].second+pref[i][j-1].second};\n          }\n        }\n      }\n      \n      \n      \n      for(int i=0;i<grid.size();i++)\n      {\n        for(int j=grid[0].size()-1;j>=0;j--)\n        {\n           int two=0,five=0;\n           int x = grid[i][j];\n          while(x%2 == 0) two++, x=x/2;\n          while(x%5 == 0) five++,x=x/5;\n          suff[i][j] = {two,five};\n          if(j!=(grid[0].size()-1))\n          {\n            suff[i][j] = {suff[i][j].first+suff[i][j+1].first,suff[i][j].second+suff[i][j+1].second};\n          }\n        }\n      }\n      \n      int ans = 0;\n      int count2=0,count5=0;\n      for(int i=0;i<grid[0].size();i++)\n      {\n         count2=0,count5=0;\n         for(int j=0;j<grid.size();j++)\n         {\n           \n           ans = max(ans,min(count2+pref[j][i].first,count5+pref[j][i].second));\n           ans = max(ans,min(count2+suff[j][i].first,count5+suff[j][i].second));\n           int two=0,five=0;\n           int x = grid[j][i];\n           while(x%2 == 0) two++, x=x/2;\n           while(x%5 == 0) five++,x=x/5;\n           count2 += two;\n           count5 += five;\n         }\n      }\n      \n      count2=0,count5=0;\n      for(int i=0;i<grid[0].size();i++)\n      {\n         count2=0,count5=0;\n         for(int j = grid.size()-1;j>=0;j--)\n         {\n           \n           ans = max(ans,min(count2+pref[j][i].first,count5+pref[j][i].second));\n           ans = max(ans,min(count2+suff[j][i].first,count5+suff[j][i].second));\n           int two=0,five=0;\n           int x = grid[j][i];\n           while(x%2 == 0) two++, x=x/2;\n           while(x%5 == 0) five++,x=x/5;\n           count2 += two;\n           count5 += five;\n         }\n      }\n      \n      return ans;\n      \n    }\n};
['C']