Algorithm to remove and shift elements in an array : <p>I am struggling to come up with a technique to achieve following:</p>

<p>Example:
Input:</p>

<pre><code>a[] = [0 1 0 1 0 1 1 0]

Array a has 8 entries. Each entry will have either 0 or 1.
</code></pre>

<p>Output:</p>

<pre><code>output = [1 3 5 6 0 2 4 7]

Output will have the indices of all the 1s first and then all the zeros.
</code></pre>

<p>Any recommendation? I am not an algo expert. I have tried solving it using heap/tree but struggling to come up with something with time complexity O(log2(N)).</p>
