Given a string s of lower and upper case English letters.
A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

0 <= i <= s.length - 2
s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.

To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.
Return the string after making it good. The answer is guaranteed to be unique under the given constraints.
Notice that an empty string is also good.
 
Example 1:
Input: s = "leEeetcode"
Output: "leetcode"
Explanation: In the first step, either you choose i = 1 or i = 2, both will result "leEeetcode" to be reduced to "leetcode".

Example 2:
Input: s = "abBAcC"
Output: ""
Explanation: We have many possible scenarios, and all lead to the same answer. For example:
"abBAcC" --> "aAcC" --> "cC" --> ""
"abBAcC" --> "abBA" --> "aA" --> ""

Example 3:
Input: s = "s"
Output: "s"

 
Constraints:

1 <= s.length <= 100
s contains only lower and upper case English letters.

Source: leetcode | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: class Solution:
    def makeGood(self, s: str) -> str:
        

Solutions:
class Solution:

	def makeGood(self, s: str) -> str:
		stack = []
		for i in s:
			if stack != [] and i.lower() == stack[-1].lower() and (i != stack[-1]):
				stack.pop()
			else:
				stack.append(i)
		return ''.join(stack)


class Solution:

	def makeGood(self, s: str) -> str:
		i = 0
		while i < len(s) - 1:
			if abs(ord(s[i]) - ord(s[i + 1])) == 32:
				s = s[:i] + s[i + 2:]
				i -= 1
				i = max(0, i)
			else:
				i += 1
		return s


class Solution:

	def makeGood(self, s: str) -> str:
		res = []
		for i in s:
			if not res:
				res.append(i)
			elif res[-1].islower() and res[-1].upper() == i:
				res.pop()
			elif res[-1].isupper() and res[-1].lower() == i:
				res.pop()
			else:
				res.append(i)
		return ''.join(res)


class Solution:

	def makeGood(self, s: str) -> str:
		if len(s) == 1:
			return s
		for i in range(len(s) - 2, -1, -1):
			if s[i].lower() == s[i + 1].lower() and s[i] != s[i + 1]:
				s = s[:i] + s[i + 2:]
				return self.makeGood(s)
		return s


class Solution:

	def makeGood(self, s: str) -> str:
		listx = [('a', 'A'), ('b', 'B'), ('c', 'C'), ('d', 'D'), ('e', 'E'), ('f', 'F'), ('g', 'G'), ('h', 'H'), ('i', 'I'), ('j', 'J'), ('k', 'K'), ('l', 'L'), ('m', 'M'), ('n', 'N'), ('o', 'O'), ('p', 'P'), ('q', 'Q'), ('r', 'R'), ('s', 'S'), ('t', 'T'), ('u', 'U'), ('v', 'V'), ('w', 'W'), ('x', 'X'), ('y', 'Y'), ('z', 'Z'), ('A', 'a'), ('B', 'b'), ('C', 'c'), ('D', 'd'), ('E', 'e'), ('F', 'f'), ('G', 'g'), ('H', 'h'), ('I', 'i'), ('J', 'j'), ('K', 'k'), ('L', 'l'), ('M', 'm'), ('N', 'n'), ('O', 'o'), ('P', 'p'), ('Q', 'q'), ('R', 'r'), ('S', 's'), ('T', 't'), ('U', 'u'), ('V', 'v'), ('W', 'w'), ('X', 'x'), ('Y', 'y'), ('Z', 'z')]
		listy = [s[0]]
		empty = ''
		for i in range(1, len(s)):
			if listy:
				a = listy.pop()
				if (a, s[i]) not in listx:
					listy.append(a)
					listy.append(s[i])
			else:
				listy.append(s[i])
		if listy:
			return ''.join(listy)
		else:
			return empty


class Solution:

	def makeGood(self, s: str) -> str:
		stack = []
		for i in range(len(s)):
			if len(stack) == 0:
				stack.append(s[i])
			elif s[i].isupper() and stack[-1].islower() and (stack[-1].upper() == s[i]):
				stack.pop(-1)
			elif s[i].islower() and stack[-1].isupper() and (stack[-1].lower() == s[i]):
				stack.pop(-1)
			else:
				stack.append(s[i])
		return ''.join(stack)