Rearrange an Array by Alternating Signs

Given an array nums containing positive and negative integers, rearrange it so that adjacent elements alternate in sign: positive, negative, positive, negative, and so on.

If the numbers of positiv...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: