You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You should return the array of nums such that the the array follows the given conditions:
- Every consecutive pair of integers have opposite signs.
- For all integers with the same sign, the order in which they were present in
numsis preserved. - The rearranged array begins with a positive integer.
Return the modified array after rearranging the elements to satisfy the aforementioned conditions.
Example 1:
Input: nums = [3,1,-2,-5,2,-4]
Output: [3,-2,1,-5,2,-4]Example 2:
Input: nums = [-1,1]
Output: [1,-1]Constraints:
2 <= nums.length <= 200,000nums.lengthis even.1 <= |nums[i]| <= 100,000numsconsists of equal number of positive and negative integers.