We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66c89f3 commit 66fa481Copy full SHA for 66fa481
leetcode_solved/leetcode_0832_Flipping_an_Image.cpp
@@ -0,0 +1,33 @@
1
+/**
2
+ * AC:
3
+ * Runtime: 8 ms, faster than 80.29% of C++ online submissions for Flipping an Image.
4
+ * Memory Usage: 9.2 MB, less than 7.07% of C++ online submissions for Flipping an Image.
5
+ *
6
+ */
7
+class Solution {
8
+public:
9
+ vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) {
10
+ int row = A.size();
11
+ int col = A[0].size();
12
+
13
+ for (int i = 0; i <= row - 1 ; i++) {
14
+ for (int j = 0; j < col / 2; j++) {
15
+ int temp = A[i][j];
16
+ A[i][j] = A[i][col - 1 - j];
17
+ A[i][col - 1 - j] = temp;
18
+ }
19
20
21
22
+ for (int j = 0; j <= col - 1; j++) {
23
+ if (A[i][j] == 0) {
24
+ A[i][j] = 1;
25
+ } else {
26
+ A[i][j] = 0;
27
28
29
30
31
+ return A;
32
33
+};
0 commit comments