DEV Community

Discussion on: ⚖️ Segregate negatives and positives ⚖️

Collapse
aarone4 profile image
Aaron Reese

Use array filter to compare i to abs(i) and separate into two arrays then spread the two new arrays into a single array. Original order is preserved and cost is 2N +1

Collapse
kaiwalyakoparkar profile image
Kaiwalya Koparkar Author

Thanks for that solution. I'll definetly try that out!