placing 0s and 1s in even and odd positions

you are given an array of integers containing only 0s and 1s. you have to place all the 0s in even position and 1s in odd position and if suppose no if 0s excedd no. of 1s or vice versa then keep them untouched. Do that in one pass without extra memory.
Ex:
input array: {0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 1 1 }
output array: {0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 }

No comments: