Question: I had an interview question which i could not solve. 

Write method (not a program) in Java Programming Language that will move all even numbers on the first half and odd numbers to the second half in an integer array. 

E.g. Input = {3,8,12,5,9,21,6,10}; Output = {12,8,6,10,3,5,9,21}.

The method should take integer array as parameter and move items in the same array (do not create another array). The numbers may be in different order than original array. This is algorithm test, so try to give as efficient algorithm as you can (possibly linear O(n) algorithm). Avoid using built in functions/API. \*

Also some basic intro to what is data structure efficiency

Answer: 
@JLRishe,

Your algorithm doesn't maintain the order. For a simple example, say {1,5,2}, you will change the array to {2,5,1}. I could not comment below your post as I am a new user and lack reputations.
public class SeperatOddAndEvenInList {

```
public static int[] seperatOddAndEvnNos(int[] listOfNumbers) {
    int oddNumPointer = 0;
    int evenNumPointer = listOfNumbers.length - 1;
    while(oddNumPointer <= evenNumPointer) {                
            if(listOfNumbers[oddNumPointer] % 2 == 0) { //even number, swap to front of last known even number
                int temp;
                temp = listOfNumbers[oddNumPointer];
                listOfNumbers[oddNumPointer] = listOfNumbers[evenNumPointer];
                listOfNumbers[evenNumPointer] = temp;
                evenNumPointer--;
            }
            else {  //odd number, go ahead... capture next element
                oddNumPointer++;
            }

    }
    return listOfNumbers;
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    int []arr = {3, 8, 12, 5, 9, 21, 6, 10};
    int[] seperatedArray = seperatOddAndEvnNos(arr);
    for (int i : seperatedArray) {
        System.out.println(i);
    }

}

```

}