problem no 33:string problem:sort the string in the decreasing order.
QUESTION:
Given a string S containing only lower case alphabets, the task is to sort it in lexigraphically-descending order.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains a string S.
Output:
For each test case, in a new line, print the sorted string.
Constraints:
1 <= T <= 100
1 <= |S| <= 105
Example:
Input:
2
geeks
for
Output:
skgee
rof
ANSWER:
#include <iostream>
#include<cstring>
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;cin>>t;
while(t--)
{
string s;
cin>>s;
sort(s.begin(), s.end(), greater<char>());
cout<<s<<"\n";
}
return 0;
}
Comments
Post a Comment