
[LeetCode] 283. Move Zeroes

·
코딩테스트/Python
🔗 Problem Linkhttps://leetcode.com/problems/move-zeroes/description/❔Thinking숫자 배열 nums가 주어지면, 0을 오른쪽으로 옮기면서 다른 숫자의 순서는 유지해야 한다.새로운 배열을 생성하지 않아야 하기 때문에, 값을 swap하는 방식을 택한다.💻Solution1. 0이 아닌 숫자의 인덱스를 찾는 방식def moveZeroes(self, nums: List[int]) -> None: for i in range(len(nums)): if nums[i] == 0: flag = False non_zero_idx = i while non_zero_idx 2. 투 포인터..