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 and Write a program to rearrange the string
such that all s appear at the beginning, followed by all s
Input format
A single line containing a binary string where denotes the length of the
string.
Output format
A single line containing the rearranged binary string.
Sample Input
Sample Output
Explanation
The given binary string has five s and five s After rearranging, all s are placed at the
beginning, followed by all s
Constraints
The input string consists only of and
The length of the input string is at least and at most class MoveZeroesStringDSAJAVA Scanner sc new ScannerSystemin; String result rearrangeBinaryStringbinaryString;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
