@jalaj
just think 0 as one array and other numbers as other array
the problem is into converted in zero one array which have to be sorted
now sort the array in O(n) with no extra space.

keep a pointer on left most 0 and find the next number in the sequence
when next number found then swap the number with left most 0 and increment
the pointer of leftmost 0
just one linear walk through the array is required.



-- 
Regards
Jitendra Kushwaha
MNNIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to