Dsa
Two Pointers
Medium
Rearrange Array Elements
You are given an array with integers where some elements are negative and others are non-negative. Rearrange the array such that negative and non-negative integers are separated. Maintain the order of the negative numbers and the non-negative numbers as they appear in the input. Return the rearranged array.
Example:
Input:
3 -1 4 -5 2 -3
Output:
-1 -5 -3 3 4 2
Key concepts
two_pointersarraysorting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now