Rearrange Array Elements by Sign
Medium · Arrays & Strings · about 10 minutes
Asked at Amazon, Google, Meta, Bloomberg, Microsoft.
nums has an even length with equal numbers of positive and negative integers. Rearrange it so signs alternate starting with a positive number, keeping the original relative order among positives and among negatives.