Given a single sentence s, check if it is a palindrome or not. Ignore white spaces and any other character you may encounter. 
Example 1:
Input:
s = race car.
Output: 1 
Explanation: processing str gives us
"racecar" which is a palindrome.
Example 2:
Input:
s = hello world.
Output: 0
Explanation: processing str gives us
"helloworld" which is not a palindrome.
Your Task:  
You dont need to read input or print anything. Complete the function sentencePalindrome() which takes a string s as input parameter and returns a boolean value denoting if sentence is a palindrome or not.
Note: The driver code prints 1 if the returned value is true, otherwise 0.
Expected Time Complexity: O(N) where N is length of s.
Expected Auxiliary Space: O(1)
Constraints:
1<= s.length() <= 10^{4}
All the alphabets used in the sentence are in lower case.

Difficulty: EASY
Tags: String algorithms

Data structures

Amortized analysis
Skill types: Amortized analysis

Data structures
Expected Time Complexity: O(N) where N is length of s.
Expected Auxiliary Space: O(1)

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

Solutions:
class Solution:

	def sentencePalindrome(self, s):
		l = 0
		h = len(s) - 1
		while l <= h:
			if s[l] < 'a' or s[l] > 'z':
				l += 1
			elif s[h] < 'a' or s[h] > 'z':
				h -= 1
			elif s[l] == s[h]:
				l += 1
				h -= 1
			else:
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		p = ''
		top = 'abcdefghijklmnopqrstvwxyz'
		for i in s:
			if i in top:
				p += i
		if p == p[::-1]:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		st = ''
		for i in range(len(s)):
			if s[i].isalpha():
				st += s[i]
		n = len(st)
		i = 0
		j = n - 1
		while i < j:
			if st[i] == st[j]:
				i += 1
				j -= 1
			else:
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		i = 0
		n = len(s)
		j = n - 1
		while i < j:
			if not s[i].isalpha():
				i += 1
			if not s[j].isalpha():
				j -= 1
			if s[i] == s[j]:
				i += 1
				j -= 1
			if s[i] != s[j] and s[i].isalpha() and s[j].isalpha():
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		a = []
		for i in s:
			if i.isalpha():
				a.append(i)
		if a == a[::-1]:
			return True
		return False


class Solution:

	def sentencePalindrome(self, s):
		(l, r) = (0, len(s) - 1)
		while l < r:
			if not s[l].isalnum():
				l += 1
			elif not s[r].isalnum():
				r -= 1
			elif s[l].lower() != s[r].lower():
				return False
			else:
				l += 1
				r -= 1
		return True


class Solution:

	def sentencePalindrome(self, s):
		start = 0
		end = len(s) - 1
		while start <= end:
			if not s[start].isalnum():
				start += 1
			elif not s[end].isalnum():
				end -= 1
			elif s[start] == s[end]:
				start += 1
				end -= 1
			else:
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		s = ''.join((ch for ch in s if ch.isalnum()))
		reverseS = s[::-1]
		if s == reverseS:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		a = ''.join((i for i in s if i.isalnum()))
		if a == a[::-1]:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		(l, r) = (0, len(s) - 1)
		while l <= r:
			if not s[l].isalpha():
				l += 1
				continue
			if not s[r].isalpha():
				r -= 1
				continue
			if s[l] != s[r]:
				return False
			l += 1
			r -= 1
		return True


class Solution:

	def sentencePalindrome(self, s):
		spe = "~`!@#$%^&*()_-+={}[];:'.,<>?/|"
		n = len(s)
		(i, j) = (0, n - 1)
		while i < j:
			if s[i] != ' ' and s[j] != ' ' and (s[i] not in spe) and (s[j] not in spe):
				if s[i] == s[j]:
					i += 1
					j -= 1
				else:
					return False
			elif s[i] == ' ' or s[i] in spe:
				i += 1
			elif s[j] == ' ' or s[j] in spe:
				j -= 1
		return True


class Solution:

	def sentencePalindrome(self, s):
		p = ''
		for i in s:
			if ord(i) > 96 and ord(i) < 123:
				p = p + i
		if p == p[::-1]:
			return True
		return False


class Solution:

	def sentencePalindrome(self, s):
		newstr = ''
		for c in s:
			if c.isalnum():
				newstr += c.lower()
		return newstr == newstr[::-1]


class Solution:

	def sentencePalindrome(self, s):
		processed = ''
		for i in s:
			if ord(i) >= 97 and ord(i) <= 122:
				processed += i
		return processed == processed[::-1]


class Solution:

	def sentencePalindrome(self, s):
		s = s.replace(' ', '')
		s = s.replace('.', '')
		s = s.replace(';', '')
		if s == s[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		s = list(s)
		(n, i) = (len(s), 0)
		while i < n:
			if ord(s[i]) < 97 or ord(s[i]) > 122:
				s.pop(i)
				n -= 1
			else:
				i += 1
		''.join(s)
		j = len(s) - 1
		i = 0
		while j > i:
			if s[i] != s[j]:
				return 0
			j -= 1
			i += 1
		else:
			return 1


class Solution:

	def sentencePalindrome(self, s):
		s = s.replace(' ', '')
		s = s.replace('.', '')
		s = s.replace(';', '')
		a = s[::-1]
		if s == a:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		c = 0
		count = 0
		for i in range(len(s)):
			if s[i].isalpha() == True:
				c += 1
		low = 0
		high = len(s) - 1
		while low < high:
			if s[low].isalpha() == True and s[high].isalpha() == True:
				if s[low] == s[high]:
					low = low + 1
					high = high - 1
					count = count + 1
				else:
					return 0
			elif s[low].isalpha() == True and s[high].isalpha() == False:
				high = high - 1
			elif s[low].isalpha() == False and s[high].isalpha() == True:
				low = low + 1
			else:
				low = low + 1
				high = high - 1
		if c // 2 == count:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		s.strip()
		k = ''
		for i in s:
			if i.isalpha():
				k += i
		if k == k[::-1]:
			return True
		return False


class Solution:

	def sentencePalindrome(self, s):
		d = ''
		for i in s:
			if i.isalpha() == True:
				d += i
		if d == d[::-1]:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		s1 = ''
		for i in s:
			if i.isalpha():
				s1 += i
		return s1 == s1[::-1]


class Solution:

	def sentencePalindrome(self, s):
		a = ''
		s = s.replace(' ', '')
		s = s.replace('.', '')
		s = s.replace(';', '')
		for i in range(0, len(s)):
			a += s[i]
		b = a[::-1]
		if a == b:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		s1 = ''
		for i in s:
			if i == ' ' or i == '.' or i == ';':
				s1 += ''
			else:
				s1 += i
		if s1 == s1[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		s = s.split()
		s = ''.join(s)
		s = list(s)
		a = []
		for i in s:
			if i.isalpha():
				a += [i]
			else:
				pass
		(i, j) = (0, len(a) - 1)
		while i <= j:
			if a[i] == a[j]:
				i += 1
				j -= 1
			else:
				return False
		return True


class Solution:

	def sentencePalindrome(self, S):
		n = len(S)
		(i, j) = (0, n - 1)
		while i < n and j >= 0 and (i != j):
			if not 'a' <= S[i] <= 'z':
				i += 1
				continue
			if not 'a' <= S[j] <= 'z':
				j -= 1
				continue
			if S[i] != S[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def sentencePalindrome(self, s):
		s1 = ''
		for i in s:
			if i.isalpha():
				s1 += i
		if s1 == s1[::-1]:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		r = ''
		for i in s:
			if i.isalpha():
				r += i
		if r == r[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		x = s.lower()
		p = []
		for i in x:
			if i.isalpha() == True:
				p.append(i)
		t = ''.join(p)
		r = t[::-1]
		if t == r:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		str = ''
		for i in s:
			if i.isalpha():
				str += i
		if str[::-1] == str:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		v = ''
		for i in s:
			if i.isalnum():
				v += i
		ss = list(v)
		i = 0
		j = len(ss) - 1
		while i < j:
			(ss[i], ss[j]) = (ss[j], ss[i])
			i += 1
			j -= 1
		ss = ''.join(ss)
		if ss == v:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		m = list(s)
		(i, j) = (0, len(m) - 1)
		while i < j:
			if m[i].isalpha() == False:
				i += 1
			elif m[j].isalpha() == False:
				j -= 1
			elif m[i] != m[j]:
				return False
			elif m[i] == m[j]:
				i += 1
				j -= 1
		else:
			return True


class Solution:

	def sentencePalindrome(self, s):
		a = list(s)
		str = ''
		for i in a:
			if i.isalnum():
				str += i.lower()
		return str == str[::-1]


class Solution:

	def sentencePalindrome(self, s):
		s = s.lower()
		a = []
		for i in s:
			if i.isalnum():
				a.append(i)
		i = 0
		j = len(a) - 1
		while i < j:
			if a[i] != a[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def sentencePalindrome(self, s):
		p = ''.join(s.split())
		l = '.;",*&%$#@!)(_'
		w = ''
		for i in p:
			if i not in l:
				w += i
		t = w[::-1]
		if t == w:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		r = ''.join((i for i in s if i.isalnum())).lower()
		if r[::-1] == r:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		a = list(s)
		i = 0
		j = len(s) - 1
		f = 0
		while i < j:
			if a[i].isalpha() and a[j].isalpha():
				if a[i] != a[j]:
					f = 1
					break
				else:
					i += 1
					j -= 1
			elif a[i].isalpha():
				j -= 1
			elif a[j].isalpha():
				i += 1
			else:
				i += 1
				j -= 1
		if f == 0:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		string = ''
		le = len(s)
		for i in range(le):
			if s[i].isalpha():
				string += s[i]
		i = 0
		j = len(string) - 1
		while i <= j:
			if string[i] != string[j]:
				return False
			i += 1
			j -= 1
		return True


class Solution:

	def sentencePalindrome(self, s):
		i = 0
		j = len(s) - 1
		while i < j:
			if not s[i] >= 'a' and s[i] <= 'z':
				i += 1
				continue
			if not s[j] >= 'a' and s[j] <= 'z':
				j -= 1
				continue
			if s[i] != s[j]:
				return False
			else:
				i += 1
				j -= 1
		return True


class Solution:

	def valid(self, ch):
		if ch >= 'a' and ch <= 'z':
			return ch

	def sentencePalindrome(self, s):
		temp = ''
		for ch in s:
			if self.valid(ch):
				temp += ch
		if temp[::-1] == temp:
			return True
		return False


class Solution:

	def sentencePalindrome(self, s):
		string = ''
		for i in s:
			if i >= 'a' and i <= 'z':
				string += i
		if string == string[::-1]:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		d = ''
		for i in s:
			if i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':
				d += i
		if d == d[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		k = s.split()
		s = ''
		for i in k:
			s += i
		al = 'abcdefghijklmnopqrstuvwxyz'
		t = ''
		for i in s:
			if i in al:
				t += i
		if t == t[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		left = 0
		right = len(s) - 1
		while left < right:
			if s[left].isalpha() == True and s[right].isalpha() == True and (s[left] == s[right]):
				left += 1
				right -= 1
				continue
			elif s[left].isalpha() == True and s[right].isalpha() == True and (s[left] != s[right]):
				return False
			elif s[right].isalpha() != True:
				right -= 1
				continue
			elif s[left].isalpha() != True:
				left += 1
				continue
		return True


class Solution:

	def sentencePalindrome(self, s):
		d = 'qwertyuiopasdfghjklzxcvbnm'
		x = ''
		for i in s:
			if i in d:
				x += i
		if x == x[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		ss = ''
		for i in s:
			if i.isalpha():
				ss += i
		x = ss[::-1]
		if x == ss:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		n = len(s)
		i = 0
		j = n - 1
		s.lower()
		while i < j:
			if not (s[i] >= 'a' and s[i] <= 'z'):
				i += 1
			elif not (s[j] >= 'a' and s[j] <= 'z'):
				j -= 1
			elif s[i] == s[j]:
				i += 1
				j -= 1
			else:
				return 0
		return 1


class Solution:

	def sentencePalindrome(self, s):
		(i, j) = (0, len(s) - 1)
		while i < j:
			(a, b) = (s[i].lower(), s[j].lower())
			if a.isalnum() and b.isalnum():
				if a != b:
					return False
				else:
					(i, j) = (i + 1, j - 1)
					continue
			if not a.isalnum():
				i += 1
			if not b.isalnum():
				j -= 1
		return True


class Solution:

	def sentencePalindrome(self, s):
		S = ''.join((char for char in s if char.isalnum()))
		return 1 if S[::-1] == S else 0


class Solution:

	def sentencePalindrome(self, s):
		S = ''
		for i in s:
			if 97 <= ord(i) <= 122:
				S += i
		if S == S[::-1]:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		string = ''
		for alphabet in s:
			if alphabet.isalpha():
				string += alphabet
		if string == string[::-1]:
			return 1
		return 0


class Solution:

	def check_palindrome(self, s):
		chars = s.strip()
		l = len(chars)
		for i in range(l):
			if i > l - i - 1:
				break
			if chars[i] != chars[l - i - 1]:
				return 0
		return 1

	def sentencePalindrome(self, s):
		chars = s.strip()
		new_s = ''
		for char in chars:
			if ord(char) >= ord('A') and ord(char) <= ord('Z'):
				new_s += char
			if ord(char) >= ord('a') and ord(char) <= ord('z'):
				new_s += char
		return self.check_palindrome(new_s)


class Solution:

	def sentencePalindrome(self, s):
		l = []
		for i in s:
			if i.isalpha():
				l.append(i)
		ans = ''.join(l)
		p = ans[::-1]
		if p == ans:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		v = ''
		s = s.replace(' ', '')
		s = s.replace('.', '')
		s = s.replace(';', '')
		for i in s:
			v = i + v
		if v == s:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		h = ''
		for i in s:
			if i >= 'a' and i <= 'z' or (i >= '0' and i <= '9'):
				h += i
		return h == h[::-1]


class Solution:

	def sentencePalindrome(self, s):
		a = ''
		for i in s.lower():
			if i.isalnum():
				a += i
		n = len(a)
		for i in range(n // 2):
			if a[i] != a[n - 1 - i]:
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		flag = True
		s = ''.join((x for x in s if x.isalnum()))
		for i in range(len(s) // 2):
			if s[i] != s[len(s) - i - 1]:
				return False
		return True


class Solution:

	def sentencePalindrome(self, s):
		S = ''
		for x in s:
			if x.isalpha():
				S += x
		if S == S[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		s1 = ''
		for i in range(len(s)):
			if 'a' <= s[i] <= 'z' or 'Z' <= s[i] <= 'Z':
				s1 += s[i]
		if s1 == s1[::-1]:
			return True
		return False


class Solution:

	def sentencePalindrome(self, s):
		s1 = s.replace(' ', '')
		s1 = s1.replace('.', '')
		s1 = s1.replace(';', '')
		s1 = s1.lower()
		s2 = s1[::-1]
		if s1 == s2:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		k = ''
		c = 0
		for i in s:
			if i.isalpha():
				k = k + i
				c += 1
		if k == k[::-1]:
			return 1
		return 0


class Solution:

	def sentencePalindrome(self, s):
		k = ''
		c = 0
		for i in s:
			if i.isalpha():
				k = k + i
				c += 1
		i = 0
		j = c - 1
		while i < j:
			if k[i] != k[j]:
				return 0
			else:
				i += 1
				j -= 1
		return 1


class Solution:

	def sentencePalindrome(self, s):
		a = s.replace(' ', '')
		a = a.replace('.', '')
		a = a.replace(';', '')
		b = a[::-1]
		if a == b:
			return True
		else:
			return False


class Solution:

	def sentencePalindrome(self, s):
		lista = []
		for item in s:
			if item.isalpha():
				lista.append(item)
		return 1 if lista == lista[::-1] else 0


class Solution:

	def sentencePalindrome(self, s):
		a = s.replace(' ', '').replace('.', '').replace(';', '')
		return a == a[-1::-1]


class Solution:

	def sentencePalindrome(self, s):
		k = ''
		for i in s:
			if i in ' .;':
				continue
			k += i
		if k[::-1] == k:
			return 1
		else:
			return 0


class Solution:

	def sentencePalindrome(self, s):
		s = ''.join((e for e in s if e.isalnum())).lower()
		return s == s[::-1]