본문 바로가기
python-algorithm

Leetcode 905. Sort Array By Parity

by 무적김두칠 2021. 7. 23.

1
2
3
4
5
6
7
8
9
pypythonpythoclass Solution:
    def sortArrayByParity(self, nums: List[int]) -> List[int]:
        tmp=[]
        tmp2=[]
        for i in range(len( nums) ) :
            if nums[i]%2==0: tmp.append(nums[i])
            else: tmp2.append(nums[i])
        tmp.extend(tmp2)
        return tmp
cs
반응형

댓글