728x90
난이도 : easy
nums 내부의 홀수를 리스트 뒷쪽으로 미는 문제
class Solution:
def sortArrayByParity(self, nums: List[int]) -> List[int]:
left = 0
for i in range(len(nums)):
if nums[i] % 2 == 0:
nums[left], nums[i] = nums[i], nums[left]
left += 1
return nums
Runtime : 2ms (57.60%)
Memory : 18.38MB (52.70%)
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 414. Third Maximum Number (0) | 2025.02.01 |
---|---|
[Python] 1051. Height Checker (0) | 2025.01.31 |
[Python] 283. Move Zeroes (0) | 2025.01.29 |
[Python] 1299. Replace Elements with Greatest Element on Right Side (0) | 2025.01.28 |
[Python] 1462. Course Schedule IV (0) | 2025.01.28 |