We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 142914f commit cb8e0eeCopy full SHA for cb8e0ee
flippin_an_image.py
@@ -0,0 +1,20 @@
1
+#mysolution
2
+class Solution:
3
+ def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]:
4
+ A_rev = [x[::-1] for x in A]
5
+ # print(A_rev)
6
+ A_inv = []
7
+ for ls in A_rev:
8
+ curr, t = ls, []
9
+ for i in range(len(curr)):
10
+ if curr[i] == 1:
11
+ t.append(0)
12
+ else:
13
+ t.append(1)
14
+ A_inv.append(t)
15
+ return A_inv
16
+
17
+#optimised
18
19
20
+ return [[1 ^ i for i in x[::-1]] for x in A]
0 commit comments