Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Check if a given string is a rotation of a palindrome
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// { Driver Code Starts
#include <bits/stdc++.h>
using namespace std;


// } Driver Code Ends

class Solution{
public:

int isRotatedPalindrome(string s)
{
map<char,int> m;
for(int i=0;i<s.length();i++){
m[s[i]]++;
}
int k=0;
for(auto e: m){
if((e.second)%2!=0){k++;}
}
if(k>1){return 0;}
return 1;
}
};

// { Driver Code Starts.
int main()
{
int t;
cin>>t;
while (t--) {
string s;
cin>>s;
Solution ob;
cout<<ob.isRotatedPalindrome(s)<<endl;
}
return 0;
} // } Driver Code Ends