Given two strings string1 and string2, remove those characters from first string(string1) which are present in second string(string2). Both the strings are different and contain only lowercase characters.
NOTE: Size of  first string is always greater than the size of  second string( |string1| > |string2|).
 
Example 1:
Input:
string1 = "computer"
string2 = "cat"
Output: "ompuer"
Explanation: After removing characters(c, a, t)
from string1 we get "ompuer".
Example 2:
Input:
string1 = "occurrence"
string2 = "car"
Output: "ouene"
Explanation: After removing characters
(c, a, r) from string1 we get "ouene".
 
Your Task:  
You dont need to read input or print anything. Complete the function removeChars() which takes string1 and string2 as input parameter and returns the result string after removing characters from string2  from string1.
Expected Time Complexity:O( |String1| + |String2| )
Expected Auxiliary Space: O(|String1|)
Constraints:
1 <= |String1| , |String2| <= 50

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3

class Solution:
    def removeChars (ob, string1, string2):
        # code here 

Solutions:
class Solution:

	def removeChars(ob, string1, string2):
		set1 = set()
		string3 = ''
		for char in string2:
			set1.add(char)
		for c2 in string1:
			if c2 not in set1:
				string3 += c2
		return string3


class Solution:

	def removeChars(ob, string1, string2):
		result = ''
		for char in string1:
			if char not in string2:
				result += char
		return result


class Solution:

	def removeChars(ob, string1, string2):
		ans = ''
		for i in string1:
			if i not in string2:
				ans += i
		return ans


class Solution:

	def removeChars(ob, string1, string2):
		a = ''
		for i in range(len(string1)):
			if string1[i] not in string2:
				a += string1[i]
		return a


class Solution:

	def removeChars(ob, s1, s2):
		r = ''
		for i in s1:
			if i not in s2:
				r += i
		return r


class Solution:

	def removeChars(ob, string1, string2):
		s = ''
		for i in string1:
			if i in string2:
				pass
			else:
				s = s + i
		return s


class Solution:

	def removeChars(ob, string1, string2):
		remove_letters = set(string2)
		res = [i for i in string1 if i not in remove_letters]
		return ''.join(res)


class Solution:

	def removeChars(ob, string1, string2):
		for i in range(len(string2)):
			string1 = string1.replace(string2[i], '')
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		for i in string2:
			if i in string1:
				string1 = string1.replace(i, '')
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		lst = []
		for i in string1:
			if i not in string2:
				lst.append(i)
		return ''.join(lst)


class Solution:

	def removeChars(ob, s, s2):
		j = ''
		for i in s:
			if i not in s2:
				j += i
		return j


class Solution:

	def removeChars(ob, str1, str2):
		for char in str2:
			if char in str1:
				str1 = str1.replace(char, '')
		return str1


class Solution:

	def removeChars(ob, string1, string2):
		s1 = list(string1)
		s = list(string2)
		for i in string1:
			if i in s:
				s1.remove(i)
		return ''.join(s1)


from collections import OrderedDict

class Solution:

	def removeChars(ob, string1, string2):
		i = 0
		while i < len(string1) - 1:
			if string1[i] in string2:
				string1 = string1[:i] + string1[i + 1:]
			else:
				i += 1
			if i >= len(string1) - 1:
				break
		if string1[-1] in string2:
			return string1[:-1]
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		list1 = []
		for i in string1:
			if i in string2:
				continue
			else:
				list1.append(i)
		return ''.join(list1)


class Solution:

	def removeChars(ob, s1, s2):
		s = ''
		for i in range(len(s1)):
			if s1[i] not in s2:
				s = s + s1[i]
		return s


class Solution:

	def removeChars(ob, str1, str2):
		s = set(str2)
		res = ''
		for i in str1:
			if i not in s:
				res += i
		return res


class Solution:

	def removeChars(ob, string1, string2):
		str = ''
		for i in string1:
			if i in string2:
				continue
			else:
				str = str + i
		return str


class Solution:

	def removeChars(ob, string1, string2):
		res = ''

		def helper(string1, string2, ind, res):
			if ind == len(string1):
				return res
			if string1[ind] not in string2:
				res += string1[ind]
			return helper(string1, string2, ind + 1, res)
		return helper(string1, string2, 0, res)


class Solution:

	def removeChars(ob, string1, string2):
		for i in string2:
			if i in string1:
				while i in string1:
					string1 = string1.replace(i, '')
			else:
				continue
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		l = []
		for j in string1:
			if j not in string2:
				l.append(j)
		return ''.join(l)


class Solution:

	def removeChars(ob, s1, s2):
		for i in s1:
			if i in s2:
				s1 = s1.replace(i, '')
		return s1


class Solution:

	def removeChars(ob, string1, string2):
		s = ''
		for i in range(len(string1) - 1, -1, -1):
			if string1[i] in string2:
				pass
			else:
				s = string1[i] + s
		return s


class Solution:

	def removeChars(self, string1, string2):
		k = ''
		for i in string1:
			if i not in string2:
				k += i
		return k


class Solution:

	def removeChars(ob, string1, string2):
		sol = ''
		for value in string1:
			if value not in string2:
				sol = sol + value
		return sol


class Solution:

	def removeChars(ob, a, b):
		ns = ''
		for i in range(0, len(a)):
			if a[i] not in b:
				ns = ns + a[i]
		return ns


class Solution:

	def removeChars(ob, string1, string2):
		i = 0
		j = 0
		str = ''
		for i in string1:
			if i not in string2:
				str += i
		return str


class Solution:

	def removeChars(ob, string1, string2):
		for i in string2:
			while i in string1:
				a = string1.find(i)
				string1 = string1.replace(i, '')
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		for s in string2:
			string1 = string1.replace(s, '')
		return string1


class Solution:

	def removeChars(self, string1, string2):
		new_string = string1
		for char in string2:
			new_string = new_string.replace(char, '')
		return new_string


class Solution:

	def removeChars(ob, string1, string2):
		s2 = set(string2)
		li = []
		for i in string1:
			if i not in s2:
				li.append(i)
		ans = ''.join(li)
		return ans


class Solution:

	def removeChars(ob, string1, string2):
		from collections import Counter
		dic = Counter(string2)
		res = ''
		for s in string1:
			if s not in dic:
				res += s
		return res


class Solution:

	def removeChars(ob, string1, string2):
		for x in string1:
			if x in string2:
				string1 = string1.replace(x, '', 1)
		return string1


class Solution:

	def removeChars(ob, string1, string2):
		string_new = ''.join([char for char in string1 if char not in string2])
		return string_new


class Solution:

	def removeChars(ob, string1, string2):
		arr = list(string1)
		string2 = list(string2)
		for i in range(len(string1)):
			if string1[i] in string2:
				arr.remove(string1[i])
		ans = ''
		for i in arr:
			ans += i
		return ans


class Solution:

	def removeChars(ob, string1, string2):
		j = 0
		i = 0
		k = ''
		for i in string1:
			if i not in string2:
				k += i
		k = ''.join(k)
		return k


class Solution:

	def removeChars(ob, string1, string2):
		l1 = list(string1)
		l2 = list(string2)
		ans = [i for i in string1 if i not in string2]
		return ''.join(ans)


class Solution:

	def removeChars(ob, string1, string2):
		s = ''
		l = list(string1)
		y = list(string2)
		for i in range(len(l)):
			if l[i] in y:
				continue
			else:
				s = s + l[i]
		return s