Codozzle Latest Questions
Given an unsorted array arr [] of size N having both negative and positive integers. The task is placing all negative element at the end of array without changing the order of positive element and negative element. Note: Solution language is your choice ...Read more
Given an unsorted array arr [] of size N having both negative and positive integers. The task is placing all negative element at the end of array without changing the order of positive element and negative element.
Note: Solution language is your choice (Java, Python, Dotnet, etc…)
Example 1:
Input:
N = 8
Arr [] = {1, -1, 3, 2, -7, -5, 11, 6}
Output:
1 3 2 11 6 -1 -7 -5
Example 2:
Input:
N=8
Arr [] = {-5, 7, -3, -4, 9, 10, -1, 11}
Output:
7 9 10 11 -5 -3 -4 -1
Your Task:
You don’t need to read input or print anything. Your task is to complete the function segregate Elements () which takes the array arr [] and its size N as inputs and store the answer in the array arr [] itself.
Constraints:
1 ≤ N ≤ 105
-105 ≤ arr [] ≤ 105