728x90
https://leetcode.com/problems/sort-array-by-parity/
class Solution:
def sortArrayByParity(self, nums: List[int]) -> List[int]:
result = []
for i in nums:
if i % 2 == 0:
result.insert(0, i)
else:
result.append(i)
return result
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 1299. Replace Elements with Greatest Element on Right Side (0) | 2023.08.26 |
---|---|
[Leetcode] 922. Sort Array By Parity II (0) | 2023.08.26 |
[Leetcode] 620. Not Boring Movies (0) | 2023.08.25 |
[Leetcode] 26. Remove Duplicates from Sorted Array (0) | 2023.08.24 |
[Leetcode] 1068. Product Sales Analysis I (0) | 2023.08.24 |