葉林
Linked with GitHub
# LeetCode - 0832. Flipping an Image ### 題目網址:https://leetcode.com/problems/flipping-an-image/ ###### tags: `LeetCode` `Easy` `陣列` `模擬` ```cpp= /* -LeetCode format- Problem: 832. Flipping an Image Difficulty: Easy by Inversionpeter */ class Solution { public: vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) { int width = A[0].size(), half = width >> 1; for (int i = 0; i != A.size(); ++i) { for (int j = 0; j < half; ++j) { A[i][j] = !A[i][j]; A[i][width - j - 1] = !A[i][width - j - 1]; swap(A[i][j], A[i][width - j - 1]); } if (width & 1) A[i][half] = !A[i][half]; } return A; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up