Last active
July 26, 2018 14:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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