class Solution { public: int equalPairs(vector<vector<int>>& grid) { int c=0; int k=grid.size()-1; while(k>=0) { vector<int>vr; vr=grid[k]; for(int i=0;i<grid.size();i++) { vector<int>vc; for(int j=0;j<grid.size();j++) { vc.push_back(grid[j][i]); } if(vr==vc) c++; } k--; } return c; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter