AlgoUniversity
  • Go Back
Discussion
Separate Even Odd :

Author

Ujjwal Srivastava

Difficulty Level : Easy

Submissions : 84

Asked In : Appdynamics

Marks :10

: 1 | : 1

Given an array $$$A$$$ of $$$n$$$ integers, write a function that segregates even and odd numbers. The function should put all even numbers first then odd numbers.

For now, you should maintain the order of even and odd numbers. For example:

arr = [3, 5, 8, 9, 0]

output = [8, 0,3, 5, 9]

Input

The first line contains an integer $$$n$$$. The next line contains $$$n$$$ integers $$$A_{i}$$$$$$(1 \le n,A_{i} \le 10^5).$$$

Output

Output the array in which the order of even and odd numbers is maintained.

Examples

Input
3
1 2 3
Output
2 1 3 
Input
4
4 6 4 8
Output
4 6 4 8 
Input
6
1 3 7 8 9 5
Output
8 1 3 7 9 5 

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.