Solution to Reorder Array from Jobdu

7 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1516

Question Name: Reorder Array

Question Description: Give an array of integers, reorder it so that, all odd numbers are before all even numbers. The order among odd numbers is kept. And so are the even numbers.

Input: first line is an integer N, saying the size of the test array. The second line contains N integers, being the test case.

Output: the reordered array.

Follow up: if the order among odd numbers and among even numbers is not kept. Could you do it in O(1) space and O(N) time?

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!