Given an array of integers A, arrange them in an alternate fashion such that every non-negative number
is followed by negative and vice-versa, starting from a negative number, maintaining the order of appearance.
The number of non-negative and negative numbers need not be equal.
If there are more non-negative numbers they appear at the end of the array.
If there are more negative numbers, they too appear at the end of the array.
Note: Try solving with O(1) extra space.
The first argument given is the integer array A.
Return the modified array.
1 <= length of the array <= 7000 -10^9 <= A[i] <= 10^9
Input 1: A = [-1, -2, -3, 4, 5] Output 1: [-1, 4, -2, 5, -3] Input 2: A = [5, -17, -100, -11] Output 2: [-17, 5, -100, -11]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.