Question bank › Arrays
Dsa Arrays Hard

Arrange Positive and Negative

You are given an array of integers with both positive and negative numbers. Your goal is to rearrange the elements such that all positive numbers are on the left side and all negative numbers are on the right side, while maintaining the original order of the elements. Print the resulting array. The input consists of one line containing integers. Example: Input: 3 -1 -4 2 5 -6 Output: 3 2 5 -1 -4 -6

Key concepts

arraystwo pointersin-place

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