ITGUY32 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

The chef has a number N, Cheffina challenges chef to form the largest number X from the digits of N.

Program:

#include<bits/stdc++.h>
using namespace std;
int main()
 {
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
   	int t;
   	cin>>t;
	for(int i=1;i<=t;i++)
	{
	    string s;
	    cin>>s;
	    sort(s.begin(),s.end());
	    for(int i=s.length()-1;i>=0;i--)cout<<s[i];
	    cout<<"\n";
	}

}

There is no mention in question that N is Given as String :frowning:

1 Like

It depends on the coder. Every coder has some optimised idea for implementation.
I do it in this way.
You can use different ways also.
But, given solution is most optimised one.