Question bank › Two Pointers
Dsa Two Pointers Medium

Rearranging Elements

You are given an array of integers where positive and negative numbers are mixed. Your task is to rearrange the elements in such a way that all positive numbers are on the left and negative numbers are on the right, while maintaining the internal order of appearance. Output the rearranged array. Input Format: - A single line containing the elements of the array space-separated. Output Format: - A space-separated string of the rearranged array. Example: Input: 3 -2 1 -5 4 Output: 3 1 -2 -5 4

Key concepts

two_pointerssortinggreedy

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.