WAP to rearrange and array with positive and negative numbers in an alternate way.
Example 1:
Input:
arr[]={-3,-5,-9,1,2,6,7,-9,45,-65}
Output:
{-3,1,-5,2,-9,6,-9,7,45,-65}
Example 2:
Input:
arr[]={-3,-5,-9,1,2,6,7,9,45,65}
Output:
{1,-3,2,-5,6,-9,7,9,45,65}
Example 3:
Input:
arr[]={3,5,9,1,-2,-6,-7,-9,-45,-65}
Output:
{3,-2,5,-6,9,-7,1,-9,-45,-65}
Published By : Kopal Jaiswal