xxxxxxxxxx
def move_negative_to_end(nums):
# Initialize pointers
left = 0
right = len(nums) - 1
# Traverse the array
while left <= right:
# If the current element is negative, swap it with the element at the end
if nums[left] < 0:
nums[left], nums[right] = nums[right], nums[left]
right -= 1
else:
left += 1
return nums
# Test the function
arr = [-4, -5, 6, -2, 3, 1, -8, 0, -9]
print(move_negative_to_end(arr))