Codeforces 1093B. Letters Rearranging Solution

  1. Solution in c++:
  2. ///**********ALLAH IS ALMIGHTY************///
  3. ///AH Tonmoy
  4. ///Department of CSE,23rd batch
  5. ///Islamic University,Bangladesh
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. int main()
  9. {
  10. int i,j,len,t;
  11. cin>>t;
  12. while(t--)
  13. {
  14. string a;
  15. cin>>a;
  16. len=a.length();
  17. sort(a.begin(),a.end());
  18. if(a[0]==a[len-1])
  19. cout<<"-1"<<endl;
  20. else
  21. cout<<a<<endl;
  22. }
  23. }
  24.  

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

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

Powered by Blogger.