Hello coders, in this tutorial, we are going to learn about Binary Sequence in C++. It can be solved by applying brute force approach. In brute force we can solve this by sorting.

**Two Pointer Approach**

In this approach, first initialize two variables as low as zero and high as size - 1. Then run a while loop untill it reaches low greater than high.

At every iteration compare array of low and array of high values if both are equal to zero then simply increment low, if both are equal to 1 then decrement high. If array of low equals to 1 and array of high equals to zero we came to know that both are at different indexes so swap low and high indexed values.

Submitted by Savala Lingesh Reddy (Lingesh)

Download packets of source code on Coders Packet

## Comments