Given a string s, check if it can be rotated to form a palindrome.
Example 1:
Input:
s = aaaab
Output: 1 
Explanation: "aaaab" can be rotated to
form "aabaa" which is a palindrome.
Your Task:  
You dont need to read input or print anything. Complete the function isRotatedPalindrome() which takes a string s as input parameter and returns 1 if rotated palindrome is possible, otherwise 0.
Expected Time Complexity: O(N^{2}) where N is length of s
Expected Auxiliary Space: O(N)
 
Constraints:
1 <= s.length() <= 10^{4}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(N^{2}) where N is length of s
Expected Auxiliary Space: O(N)

Starter code:
#User function Template for python3
class Solution:
	def isRotatedPalindrome(self, s):
		#code here

Solutions:
class Solution:

	def isRotatedPalindrome(self, s):
		if len(set(s)) == len(s):
			return 0
		d = {}
		for i in s:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		c = 0
		for i in d:
			if d[i] % 2:
				if c:
					return 0
				c = 1
		return 1


class Solution:

	def isRotatedPalindrome(self, li):

		def ispalindrome(s):
			i = 0
			j = len(s) - 1
			while i <= j:
				if s[i] != s[j]:
					return False
				i += 1
				j -= 1
			return True
		for i in range(len(li)):
			x = li[i:] + li[:i]
			if ispalindrome(x):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		d = {}
		for ch in s:
			if ch in d.keys():
				d.pop(ch)
			else:
				d[ch] = 1
		if len(d) > 1:
			return 0
		else:
			return 1


from collections import Counter

class Solution:

	def isRotatedPalindrome(self, s):
		ans = 0
		for (i, j) in Counter(s).items():
			if j % 2 == 0:
				continue
			else:
				ans += 1
		return '1' if ans <= 1 else '0'


class Solution:

	def isRotatedPalindrome(self, s):
		store = set()
		for item in s:
			if item in store:
				store.remove(item)
			else:
				store.add(item)
		if len(store) > 1:
			return 0
		n = len(s)
		body = s + s
		for i in range(n):
			string = body[i:i + n]
			if string == string[::-1]:
				return 1
		return 0


class Solution:

	def isPalindrome(self, s):
		length = len(s)
		if length % 2:
			left = right = int(length / 2)
		else:
			mid = int(length / 2)
			(left, right) = (mid - 1, mid)
		while right < length:
			if s[left] != s[right]:
				return False
			left -= 1
			right += 1
		return True

	def isRotatedPalindrome(self, s):
		newString = s
		for i in range(len(s)):
			newString = newString[-1] + newString[:-1]
			if self.isPalindrome(newString):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		if self.isPal(s):
			return 1
		n = len(s)
		for i in range(n - 1):
			s1 = s[i + 1:n]
			s2 = s[0:i + 1]
			s1 += s2
			if self.isPal(s1):
				return 1
		return 0

	def isPal(self, s):
		l = 0
		h = len(s) - 1
		while h > l:
			l += 1
			h -= 1
			if s[l - 1] != s[h + 1]:
				return False
		return True


class Solution:

	def ispalindrome(string):
		l = 0
		h = len(string) - 1
		while h > l:
			if string[l] != string[h]:
				return 0
			l += 1
			h -= 1
		return 1

	def isRotatedPalindrome(self, s):
		if Solution.ispalindrome(s):
			return 1
		n = len(s)
		for i in range(n - 1):
			string1 = s[i + 1:n]
			string2 = s[0:i + 1]
			string1 += string2
			if Solution.ispalindrome(string1):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		c = ''.join(reversed(s))
		S = s + s
		n = len(s)
		j = n
		for i in range(0, len(S)):
			s1 = S[i:j]
			j += 1
			if s1 == c:
				return 1
				break
		return 0


from collections import deque

class Solution:

	def isRotatedPalindrome(self, s):
		stack = deque()
		index = 0
		while index < len(s):
			if len(stack) == 0:
				stack.append(s[index])
			else:
				currentChar = stack.pop()
				if currentChar != s[index]:
					stack.append(currentChar)
					stack.append(s[index])
			index += 1
		while len(stack) > 1:
			if stack.pop() != stack.popleft():
				return 0
		return 1


class Solution:

	def isRotatedPalindrome(self, s):
		if len(s) == 1:
			return 1

		def helper(x):
			left = 0
			right = len(x) - 1
			while left < right:
				if x[left] != x[right]:
					return False
				left += 1
				right -= 1
			return True
		for i in range(len(s)):
			new = s[i:] + s[:i]
			if helper(new):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):

		def isk(t):
			p = 0
			y = len(t) - 1
			while p <= y:
				if t[p] == t[y]:
					p += 1
					y -= 1
				else:
					return False
			return True
		if s == s[::-1]:
			return 1
		for h in range(len(s)):
			t = s[h:] + s[:h]
			if isk(t):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		d = {}
		k = 0
		for i in s:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for i in d.values():
			if i % 2 != 0:
				k += 1
		if k > 1:
			return 0
		return 1


class Solution:

	def isPalindrome(self, string):
		l = 0
		h = len(string) - 1
		while h > l:
			l += 1
			h -= 1
			if string[l - 1] != string[h + 1]:
				return False
		return True

	def isRotatedPalindrome(self, string):
		if self.isPalindrome(string):
			return 1
		n = len(string)
		for i in range(n - 1):
			string1 = string[i + 1:n]
			string2 = string[0:i + 1]
			string1 += string2
			if self.isPalindrome(string1):
				return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		n = len(s)
		for i in range(n):
			s = s[n - 1:] + s[:n - 1]
			j = 0
			k = n - 1
			while j <= k:
				if s[j] != s[k]:
					break
				j += 1
				k -= 1
			if j > k:
				return 1
		return 0


from collections import Counter

class Solution:

	def isRotatedPalindrome(self, s):
		a = Counter(s)
		odd = 0
		for i in a.values():
			if i % 2 == 0:
				pass
			else:
				odd = odd + 1
		if odd < 2:
			return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		hashmap = {}
		for i in s:
			hashmap[i] = hashmap.get(i, 0) + 1
		odd = 0
		for val in hashmap.values():
			if val % 2 != 0:
				odd += 1
		if odd < 2:
			return 1
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		if s == s[::-1]:
			return 1
		ind = []
		n = len(s)
		for i in range(n - 1):
			if s[i] == s[i + 1]:
				ind.append(i)
		for k in ind:
			new = s[k + 1:] + s[:k + 1]
			if new == new[::-1]:
				return 1
				exit(0)
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		l = len(s)
		if s == s[::-1]:
			return 1
		for i in range(1, l):
			if s[i] == s[i - 1]:
				new = s[i:] + s[:i]
				if new == new[::-1]:
					return 1
				else:
					new = ''
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		m = {}
		for i in s:
			if i in m:
				m[i] = m[i] + 1
			else:
				m[i] = 1
		c = 0
		for i in m.values():
			if len(s) % 2 == 0 and i % 2 == 1:
				return 0
			if len(s) % 2 == 1 and i % 2 == 1:
				c = c + 1
				if c > 1:
					return 0
		return 1


class Solution:

	def isRotatedPalindrome(self, s):
		for i in range(int(len(s))):
			t = s[1:len(s)]
			t = t + s[0]
			n = int(len(t))
			c = 0
			for j in range(int(len(t) / 2)):
				if t[j] == t[n - 1 - j]:
					c = c + 1
				else:
					break
			if c == int(n / 2):
				return 1
			s = t
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		if s == s[::-1]:
			return 1
		ind = []
		n = len(s)
		for i in range(n - 1):
			if s[i] == s[i + 1]:
				ind.append(i)
		for k in ind:
			(f, f1) = (1, 0)
			(i, j) = (k, k + 1)
			c = 0
			while c < n // 2:
				if s[i] != s[j]:
					f = 0
					f1 = 1
					break
				i -= 1
				i = i % n
				j += 1
				j = j % n
				c += 1
			if f:
				return f
				exit(0)
		return 0


class Solution:

	def isRotatedPalindrome(self, s):
		f = {}
		for i in s:
			if i in f:
				f[i] += 1
			else:
				f[i] = 1
		odd_number_count = 0
		for char in f:
			if f[char] % 2 == 1:
				odd_number_count += 1
		if odd_number_count > 1:
			return 0
		else:
			return 1


class Solution:

	def isRotatedPalindrome(self, s):
		sol = []
		alphabets = list(set(s))
		for i in alphabets:
			sol.append(s.count(i) % 2)
		if sol.count(1) > 1:
			return 0
		else:
			return 1