Separating Negative and Positive numbers(Contest)
Separating Negative and Positive numbers easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Separating Negative and Positive numbers easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Separate an array of positive and negative integers while maintaining the relative order of the items using merge sort. All positive numbers should come after negative ones, with the relative order remaining the same. Input The first line of input will be n, which represents the array's length, followed by the n array items in the second line.
Constraints: 0< n <=100000 1<= arr[i] <= 100000 Output The result should be an array with negative numbers separated at the front and the relative order of the elements preserved. Example
Sample Input: 6 -1 1 2 -4 -6 5
Output: -1 -4 -6 1 2 5
link: