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

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.