#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<string>
using namespace std;
class solution
{
public:
void solve()
{
int n;
cin >> n;
string s1, s2;
cin >> s1;
s2 = s1;
sort(s1.begin(), s1.end());
for (int i = 1; i <= n; i++)
{
if(s2[i]!=s1[i])
swap(s2[i], s2[n-1-i]);
}
if (s1==s2)
cout << "YES
";
else
cout << "NO
";
}
};
int main()
{
solution ss;
int t;
cin >> t;
while (t--)
{
ss.solve();
}
return 0;
}
Code Example |
---|
Cpp :: c plus |
Cpp :: c++ constructor inheritance |
Cpp :: C++ Multilevel Inheritance |
Cpp :: big o notation practice c++ |
Cpp :: ordine crescente di numeri indefiniti in c++ |
Cpp :: Operatore ternario c++ |
Cpp :: create dynamic variable c++ |
Cpp :: destiny child |
Cpp :: cpp stacks |
Cpp :: Fill 2-dimensional array with value |
Cpp :: ue4 c++ add tag |
Cpp :: Edmonds-Karp algorithm C++ |
Cpp :: c++ arrays |
Cpp :: what type is this c++ |
Cpp :: c++ tuple example |
Cpp :: semi colon in argument list c++ |
Cpp :: c++ cout update percentage |
Cpp :: huffman encoding in c++ |
Cpp :: [3,2,4,-1,-4] |
Cpp :: JAJA |
Cpp :: template design pattern |
Cpp :: partition in STL using vector |
Cpp :: assignment of single field in struct in solidity |
Cpp :: number triangle c++ |
Cpp :: C++ if...else Statement |
Cpp :: sort in descending order c++ |
Cpp :: string class cpp |
Cpp :: how to use comparitor in priority queu in c++ |
Cpp :: gcd of two number in c++ stl |
Cpp :: Chef and Feedback codechef solution in cpp |