Flipping an Image
Arrangement
Problem
Thought Process
Solution
class Solution:
def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]:
N = len(A[0])
for i in range(len(A)):
for j in range(len(A[0])):
if A[i][j] == 1:
A[i][j] = 0
elif A[i][j] == 0:
A[i][j] = 1
for i in range(len(A)):
for j in range(len(A[0])//2):
temp = A[i][N-1-j]
A[i][N-1-j] = A[i][j]
A[i][j] = temp
return(A)
Key Facts
Time Complexity
Last updated