If it's that way, then it's nothing different from an everyday sorting
problem, except the 0s go at the end.
You can replace 0 with a large value that hasn't been used say 32760
or something and sort using quicksort.
After you're done sorting, replace 32760s with 0s. If the array is
already sorted, then it's a question of pushing the 0s
at the end. People with posts above have given good solutions for the
same.

Also, people, when you post questions can you please be specific? Try
not to leave ambiguities in the Q, or leave it open
to interpretation. Also, a suitable and problem related title helps
catch attention and fuel the discussion. :-)


On Jun 28, 5:36 am, umesh kewat <[email protected]> wrote:
> Hi All,
>
> here you people are considering series as sorted except 0 as input and have
> to rearrange like mansion output.. do it like if there input is unsorted and
> will get same output..
> e.g.
>
> input: 0,2,0,8,0,1,0,4,,6,7,5,0,0,0,3
>
> output: 1 2 3 4 5 6 7 8 0 0 0 0 0 0
>
> time complexity: in O(n) not possible try it to in O(nlogn)
> space complexity : O(1)
>

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

Reply via email to