Given a Binary String S (the string that contains only 0's and 1's). Find the minimum number of palindromic subsequences that are needed to be removed such that string S becomes empty.
Example 1:
Input: N = 5, S = "10001"
Output: 1
Explanation: We can remove whole S, as
S is already a palindrome.
Ã¢â¬â¹Example 2: 
Input: N = 8, S = "10001001"
Output: 2
Explanation: First we'll remove sub-
sequence "111" and then "00000".
Your Task:  
You don't need to read input or print anything. Your task is to complete the function MinRemove() which takes the length of string and the string as inputs and returns the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{8}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

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


Solutions:
class Solution:

	def MinRemove(self, n, s):
		if s == s[::-1]:
			return 1
		return 2


class Solution:

	def MinRemove(self, n, s):
		k = str(s)
		p = k[::-1]
		if k == p:
			return 1
		else:
			return 2


class Solution:

	def MinRemove(self, n, s):
		(i, j) = (0, n - 1)
		while i < n and j >= 0 and (i != j):
			if s[i] != s[j]:
				return 2
			i += 1
			j -= 1
		return 1


class Solution:

	def MinRemove(self, n, s):
		s1 = s[::-1]
		if s == s1:
			return 1
		else:
			return 2


class Solution:

	def MinRemove(self, n, s):
		if s.count('0') == 0 or s.count('1') == 0 or s == s[::-1]:
			return 1
		else:
			return 2


class Solution:

	def MinRemove(self, n, s):
		isPal = True
		for i in range(int(n / 2)):
			if s[i] != s[n - i - 1]:
				isPal = False
		if isPal == True:
			return 1
		return 2


class Solution:

	def MinRemove(self, n, s):
		if len(s) == 0:
			return 0
		if self.Ispelindrome(n, s):
			return 1
		return 2

	def Ispelindrome(self, n, s):
		i = 0
		j = n - 1
		while j > i:
			if s[i] != s[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def MinRemove(self, n, s):
		if s == s[::-1]:
			return 1
		return 2
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input().strip())
		s = input().strip()
		obj = Solution()
		print(obj.MinRemove(n, s))


class Solution:

	def MinRemove(self, n, s):
		if s[0] == '':
			return 0
		l = 0
		t = len(s) - 1
		while l < t:
			if s[l] != s[t]:
				return 2
			l += 1
			t -= 1
		return 1


class Solution:

	def MinRemove(self, n, s):
		cnt = 0
		if s == s[::-1]:
			return 1
		else:
			return 2


def isPal(s):
	i = 0
	j = len(s) - 1
	while i <= j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

class Solution:

	def MinRemove(self, n, s):
		if isPal(s):
			return 1
		return 2


class Solution:

	def MinRemove(self, n, s):
		return int(s[::-1] == s) or 2


class Solution:

	def MinRemove(self, n, s):
		if len(s) == 0:
			return 0
		start = 0
		end = n - 1
		while start < end:
			if s[start] == s[end]:
				start += 1
				end -= 1
			else:
				return 2
		return 1


class Solution:

	def MinRemove(self, n, s):
		for i in range(n):
			if s[i] != s[n - i - 1]:
				return 2
		return 1


class Solution:

	def MinRemove(self, n, s):
		k = ''
		for i in s:
			k = i + k
		if k == s:
			return 1
		else:
			return 2