Move All Negative Numbers To Beginning
Rearrange a given array 'ARR' with 'N' integers so that all negative numbers appear before all positive numbers.
Follow Up:
Can you solve this in O(1) auxiliary space?
Note:
The order of elements in the resulting array is not important.
Example:
Input:
ARR = [1, 2, -3, 4, -4, -5]
Output:
[-3, -5, -4, 2, 4, 1]
Constraints:
1 <= T <= 10
1 <= N <= 5 * 104
-105 <= ARR[i] <= 105
Where ‘T’ represents the number of test cases and ‘N’ represents the number of elements present in the array.
Note:
You do not need to print anything, it has already been taken care of. Just return the resulting array.
Be the first one to answer
Add answer anonymously...
Top Samsung Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app