比较简单的模拟题。

#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

相关文章:

  • 2021-07-24
  • 2021-08-26
  • 2021-09-19
  • 2021-07-04
  • 2021-11-17
  • 2021-12-06
  • 2021-05-31
猜你喜欢
  • 2021-05-09
  • 2021-08-06
  • 2021-07-22
  • 2021-10-02
  • 2021-10-22
  • 2021-08-26
相关资源
相似解决方案