2019年3月8日 905. Sort Array By Parity、832. Flipping an Image

比较简单的模拟题。

#905
class Solution(object):
    def sortArrayByParity(self, A):
        """
        :type A: List[int]
        :rtype: List[int]
        """
        ret = []
        for i in A:
            if i % 2 == 0:
                ret.insert(0, i)
            else:
                ret.append(i)
        return ret


#832
class Solution(object):
    def flipAndInvertImage(self, A):
        """
        :type A: List[List[int]]
        :rtype: List[List[int]]
        """
        ret =[]
        for i in A:
            i.reverse()
            ret.append([(j+1)%2 for j in i])
        return ret
原文地址:https://www.cnblogs.com/seenthewind/p/10493888.html