Question: Problem Description You are given a binary string composed of ' 0 ' and ' 1 ' . Write a program to rearrange the string

Problem Description
You are given a binary string composed of '0' and '1'. Write a program to rearrange the string
such that all '0's appear at the beginning, followed by all '1's.
Input format
A single line containing a binary string s(1|s|10??3), where |s| denotes the length of the
string.
Output format
A single line containing the rearranged binary string.
Sample Input 1
0101010101
Sample Output 1
0000011111
Explanation
The given binary string has five '0's and five '1's. After rearranging, all '0's are placed at the
beginning, followed by all '1's.
Constraints
The input string consists only of '0' and '1'.
The length of the input string is at least 1 and at most 10??3.class MoveZeroesStringDSAJAVA{ Scanner sc = new Scanner(System.in); String result = rearrangeBinaryString(binaryString);}}
}
Problem Description You are given a binary string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!