I have an array unordered i want all the zero’s at the odd position and all the ones at even position
and rest of the number after zero’s and 1’s

Count the number of ones and number of zeros, store them in variables say num_zero and num_one. Now create an array with those many number of ones and zeros in whichever position you want(in this case alternatively). Go to the original array and copy all the non-(zero-and-one) numbers to the end of the new array. O(n) time. There should be O(1) space problem i suppose, try it but this is the first thing that came to mind. Hope it helps

it won’t do i tried this

No, you didn’t try this !!

1 Like

@deeps1010 Do one thing. Forget whatever you have learnt, buy this book : http://www.amazon.com/s?rh=n%3A3967%2Cp_lbr_one_browse-bin%3ADennis+M.+Ritchie “LEARN”(notice all capitals ??) and then “actually do what I said” and then talk !!

How would a buying a book solve the problem?

1 Like

@tech_boy I said buy and “LEARN”(with all capitals).