CodeChef Starters 30 Division 4 (Rated) Balanced Reversals Problem Code: BALREV Solution
Problem Link: https://www.codechef.com/problems/BALREV
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,n,i,o,z;
cin>>t;
while(t--)
{
o=z=0;
cin>>n;
string str;
cin>>str;
for(i=0;i<str.size(); i++)
{
if(str[i]=='1')
o++;
else
z++;
}
for(i=0;i<z;i++)
cout<<"0";
for(i=0;i<o;i++)
cout<<"1";
cout<<endl;
}
}
No comments