class Solution {
public:
vector<vector<int>> flipAndInvertImage(vector<vector<int>>& a) {
int n=a.size();
for(int i=0;i<n;i++)
{
reverse(a[i].begin(),a[i].end());
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]==0) a[i][j]=1;
else a[i][j]=0;
}
}
return a;
}
};
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