Skip to content

Instantly share code, notes, and snippets.

@lealLuo
Last active July 26, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lealLuo/bfc0207a6371366cb071d61f0fac3601 to your computer and use it in GitHub Desktop.
Save lealLuo/bfc0207a6371366cb071d61f0fac3601 to your computer and use it in GitHub Desktop.
URL:https://leetcode.com/problems/flipping-an-image/description/ I made a big mistake here in Python. I use ListCopy = ListOrigin to copy the List, then change the value in ListOrigin with the value of copy version. But in python, If I simply use *Li
class Solution:
def flipAndInvertImage(self, A):
"""
:type A: List[List[int]]
:rtype: List[List[int]]
"""
def invert(value):
if value==1:
return 0
else:
return 1
for ListIn in A:
ListCopy = ListIn[:] # cannot use ListCopy = List, otherwise error will appear
print (ListCopy)
for i in range(len(A[0])):
ListIn[i] = invert(ListCopy[len(A[0])-i-1])
return A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment