Tuesday, 7 March 2017

Geeksforgeeks Solution For " Binary Array Sorting "

GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Given a binary array, sort it in non-decreasing order

Submit Your Solution :- Click Here 


Solution :-

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() 

{
int t1;
cin>>t1;
while(t1--)
{
   int n,i,t;
   cin>>n;
   vector <int> arr(n);
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   sort(arr.begin(),arr.end());
   
   for(i=0;i<n;i++)
   {
       cout<<arr[i]<<" ";
   }
   cout<<endl;
}

return 0;
}

Output:-

Geeksforgeeks Solution For " Binary Array Sorting "

No comments:
Write comments

Recommended Posts × +