Answer key
They’re very clear, so do what they say, flip it horizontally first, and then flip it backwards.
Horizontal reverse can use its own reverse, reverse directly and 1 XOR can be.
code
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 < A[0].size(); j++){
A[i][j] = A[i][j]^1;
}
}
return A;
}
};
Read More:
- PCIe Lane flip and PN flip (Lane reverse and polarity)
- [leetcode] 926. Flip string to monotone increasing problem solving report (Python)
- VTK cultivation 26: basic operation of image_ Three dimensional image slice extraction
- Ueditor paste word image and upload image file automatically
- Common causes of Leetcode Runtime Error
- Leetcode: 7. Reverse Integer(JAVA)
- Leetcode solution 189 Rotate Array Java version
- [docker] error in deleting image: image is referenced in multiple repositories
- Ant Design upload listtype = “picture card” realizes multi image upload and click preview image encapsulation
- LeetCode 332. Reconstruct Itinerary
- LeetCode 23. Merge k Sorted Lists(java)
- The sum of the two numbers of leetcode
- Leetcode-234: palindrome linked list
- Leetcode 34 finds the first and last position of an element in the sorted array (medium)
- ImageIO.read () unsupported image type when reading picture_ exception Unsupported Image Type
- Image proxy settings Flash + JavaScript
- Bitmap, cache and fresco Android image loading Library
- On the problem of from PIL import image
- Installing the image J plug-in
- Python opencv (3) get image size