Given a string S, remove all the characters other than the alphabets.
Example 1:
Input: S = "$Gee*k;s..fo, r'Ge^eks?"
Output: GeeksforGeeks
Explanation: Removed charcters other than
alphabets. 
 
Example 2:
Input:  S = "{{{}}> *& ^%*)"
Output: -1
Explanation: There are no alphabets.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function removeSpecialCharacter() which takes string S as input parameter and returns the resultant string. Return "-1" if no alphabets remain.
 
Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(|s|)
 
Constraints:
1 <= |S| <= 10^{5}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(|s|)

Starter code:
#User function Template for python3



class Solution:

    def removeSpecialCharacter (self, S):

		#code here

Solutions:
class Solution:

	def removeSpecialCharacter(self, S):
		l = ''
		for i in S:
			if i.isalpha():
				l = l + i
		if len(l) > 0:
			return l
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		str1 = ''
		for i in range(len(S)):
			if S[i].isalpha() == True:
				str1 = str1 + S[i]
		if len(str1) > 0:
			return str1
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		l = []
		k = ''
		for i in S:
			if i.isalpha():
				k += i
		if k == '':
			return -1
		else:
			return k


import string

class Solution:

	def removeSpecialCharacter(self, S):
		str = ''
		for i in S:
			if i in string.ascii_letters:
				str += i
		if not str:
			return -1
		return str


class Solution:

	def removeSpecialCharacter(self, S):
		alph = ''
		for i in S:
			if i.isalpha():
				alph += i
		if len(alph) < 1:
			return -1
		return alph


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for i in S:
			if ord(i) < 65 or ord(i) > 122:
				pass
			else:
				if ord(i) == 91 or ord(i) == 92 or ord(i) == 93 or (ord(i) == 94) or (ord(i) == 95) or (ord(i) == 96):
					continue
				s = s + i
		if len(s) != 0:
			return s
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		k = '!@#$%^&*()_-+=\\|}] {[\'";:<>.1234567890,.?/'
		j = ''
		for i in range(len(S)):
			if S[i] not in k:
				j = j + S[i]
		if len(j) > 0:
			return j
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		d = ''
		for i in S:
			if i.isalpha() == True:
				d += i
		if d != '':
			return d
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for i in S:
			if i.isalpha():
				s += i
		if s:
			return s
		return -1


class Solution:

	def removeSpecialCharacter(self, S):
		l = []
		for i in S:
			if 65 <= ord(i) <= 90 or 97 <= ord(i) <= 122:
				l.append(i)
		S = ''.join(map(str, l))
		if S == '':
			return -1
		return S


class Solution:

	def removeSpecialCharacter(self, S):
		res = ''
		for i in S:
			if i.isalpha():
				res += i
		if not res:
			return '-1'
		return res


class Solution:

	def removeSpecialCharacter(self, S):
		str = ''
		for i in S:
			if ord(i) >= 65 and ord(i) < 91 or (ord(i) >= 97 and ord(i) < 123):
				str += i
		if len(str) == 0:
			return -1
		return str


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for i in S:
			if ord(i) >= 65 and ord(i) < 91 or (ord(i) >= 97 and ord(i) < 123):
				s += i
		if s == '':
			return -1
		return s


class Solution:

	def removeSpecialCharacter(self, S):
		list1 = [i for i in S if i.isalpha()]
		if not list1:
			return -1
		return ''.join(list1)


class Solution:

	def removeSpecialCharacter(self, s):
		s1 = ''
		for i in s:
			if ord(i) >= 65 and ord(i) <= 90 or (ord(i) >= 97 and ord(i) <= 122):
				s1 += i
		if len(s1) == 0:
			return '-1'
		return s1


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for i in range(len(S)):
			if S[i].isalpha():
				s += S[i]
		if s:
			return s
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		a = ''
		for i in S:
			if i.isalpha():
				a += i
			else:
				continue
		if a.isalpha():
			return a
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		newst = ''
		for i in S:
			if 'a' <= i <= 'z' or 'A' <= i <= 'Z':
				newst += i
		if newst == '':
			return -1
		return newst


class Solution:

	def removeSpecialCharacter(self, S):
		d = ''
		a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
		for i in S:
			if i in a:
				d += i
		if len(d) == 0:
			return -1
		else:
			return d


class Solution:

	def removeSpecialCharacter(self, S):
		string = ''
		for index in S:
			if index >= 'A' and index <= 'Z' or (index >= 'a' and index <= 'z'):
				string += index
		if len(string) == 0:
			return -1
		else:
			return string


class Solution:

	def removeSpecialCharacter(self, S):
		ans = ''
		n = len(S)
		for i in range(n):
			if 65 <= ord(S[i]) <= 90 or 97 <= ord(S[i]) <= 122:
				ans += S[i]
		if ans == '':
			return -1
		return ans


class Solution:

	def removeSpecialCharacter(self, S):
		str2 = ' '
		for i in range(len(S)):
			if S[i].isalpha():
				str2 += S[i]
		if str2 == ' ':
			return -1
		else:
			return str2.strip()


class Solution:

	def removeSpecialCharacter(self, S):
		a = ''
		for i in S:
			if i.isalpha():
				a += i
		if len(a) == 0:
			return -1
		return a


class Solution:

	def removeSpecialCharacter(self, S):
		a = ''
		count = 0
		for i in S:
			if i.isalpha():
				a += i
				count += 1
		if count == 0:
			return -1
		else:
			return a


class Solution:

	def removeSpecialCharacter(self, S):
		result = ''
		for i in S:
			if i.isalpha():
				result += i
		if result:
			return result
		else:
			return '-1'


class Solution:

	def removeSpecialCharacter(self, S):
		p = ''
		for i in range(len(S)):
			ch = S[i]
			if ch >= 'a' and ch <= 'z' or (ch >= 'A' and ch <= 'Z'):
				p = p + ch
			else:
				p = p
		return p if p else -1


class Solution:

	def removeSpecialCharacter(self, S):
		l = []
		for i in S:
			if i.isalpha():
				l.append(i)
		l = ''.join(l)
		if l.isalpha():
			return ''.join(l)
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		ans = ''
		change = -1
		for ch in S:
			if ch >= 'a' and ch <= 'z':
				ans += ch
				change = 1
			elif ch >= 'A' and ch <= 'Z':
				ans += ch
				change = 1
		if change == -1:
			return -1
		return ans


class Solution:

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

	def removeSpecialCharacter(self, S):
		temp = ''
		count = 0
		for ch in S:
			if self.valid(ch):
				temp += ch
				count = 1
		if count == 0:
			return -1
		return temp


class Solution:

	def removeSpecialCharacter(self, S):
		result = ''
		for char in S:
			if char.isalpha():
				result += char
		if len(result) == 0:
			return '-1'
		else:
			return result


class Solution:

	def removeSpecialCharacter(self, S):
		res = ''.join([e for e in S if e.isalpha()])
		return res if res != '' else -1


class Solution:

	def removeSpecialCharacter(self, S):
		res = ''
		for i in S:
			if ord(i) >= 65 and ord(i) <= 90:
				res += i
			elif ord(i) >= 97 and ord(i) <= 122:
				res += i
		if len(res) == 0:
			return -1
		else:
			return res


class Solution:

	def removeSpecialCharacter(self, S):
		res = ''
		for s in S:
			if s.isalpha():
				res += s
		return res if len(res) != 0 else -1


import re

class Solution:

	def removeSpecialCharacter(self, S):
		s = ''.join(re.findall('[A-Za-z]', S))
		if s:
			return s
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for x in S:
			if x.isalpha():
				s += x
		return s if s else -1


class Solution:

	def removeSpecialCharacter(self, S):
		str2 = ''
		for i in range(len(S)):
			if 'A' <= S[i] <= 'Z' or 'a' <= S[i] <= 'z':
				str2 += S[i]
			else:
				pass
		if len(str2) > 0:
			return str2
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		al = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
		s = ''
		for i in S:
			if i in al:
				s += i
		if len(s) >= 1:
			return s
		return -1


class Solution:

	def removeSpecialCharacter(self, S):
		s = ''
		for i in S:
			if i.isalpha():
				s += str(i)
		if len(s) > 0:
			return s
		return -1


class Solution:

	def removeSpecialCharacter(self, S):
		alphabet = 'abcdefghijklmnopqrstuvwxyz'
		alphabet1 = alphabet.upper()
		output = ''
		for item in S:
			if item in alphabet or item in alphabet1:
				output += item
		if len(output) > 0:
			return output
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		new = ''
		for i in S:
			if i >= 'A' and i <= 'Z':
				new += i
			elif i >= 'a' and i <= 'z':
				new += i
		if new == '':
			return -1
		else:
			return new


class Solution:

	def removeSpecialCharacter(self, S):
		temp = ''
		for e in S:
			if e.isalpha():
				temp += e
		return temp if temp != '' else -1


class Solution:

	def removeSpecialCharacter(self, s):
		str1 = ''
		for i in s:
			if not self.isalpha(i):
				continue
			else:
				str1 += i
		if len(str1) == 0:
			return -1
		else:
			return str1

	def isalpha(self, i):
		if i >= 'a' and i <= 'z':
			return True
		if i >= 'A' and i <= 'Z':
			return True
		return False


class Solution:

	def removeSpecialCharacter(self, S):
		sf = ''
		for i in range(0, len(S)):
			if ord(S[i]) in range(97, 123) or ord(S[i]) in range(64, 91):
				sf = sf + S[i]
		if len(sf) == 0:
			return -1
		else:
			return sf


class Solution:

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


class Solution:

	def removeSpecialCharacter(self, S):
		res = ''
		for i in S:
			if i.islower() or i.isupper():
				res = res + i
		if len(res) == 0:
			return -1
		else:
			return res


class Solution:

	def removeSpecialCharacter(self, S):
		a = '-1'
		s = ''
		for i in S:
			if i >= 'a' and i <= 'z' or (i >= 'A' and i <= 'Z'):
				s += i
		if len(s) != 0:
			return s
		else:
			return a


class Solution:

	def removeSpecialCharacter(self, S):
		newString = ''
		for char in S:
			if char >= 'A' and char <= 'Z' or (char >= 'a' and char <= 'z'):
				newString += char
		if newString:
			return newString
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, s):
		out = ''
		for i in range(len(s)):
			if s[i].isalpha():
				out += s[i]
		return out if len(out) > 0 else -1


class Solution:

	def removeSpecialCharacter(self, S):
		ans = ''
		for i in S:
			if i.isalpha():
				ans += i
			else:
				i.replace(i, '')
		if len(ans) > 0:
			return ans
		else:
			return -1


class Solution:

	def removeSpecialCharacter(self, S):
		l1 = []
		for i in S:
			if i.isalpha():
				l1.append(i)
		if len(l1) == 0:
			return '-1'
		return ''.join(l1)


class Solution:

	def removeSpecialCharacter(self, S):
		al = 'abcdefghijklmnopqrstuvwxyz'
		res = ''
		for i in S:
			if i.lower() in al:
				res += i
		return res if len(res) > 0 else -1


class Solution:

	def removeSpecialCharacter(self, S):
		l = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
		res = ''
		for each in S:
			if each in l:
				res += each
		if len(res) == 0:
			return -1
		else:
			return res