Given a string without spaces, the task is to remove duplicates from it. 
Note: The original order of characters must be kept the same. 
Example 1:
Input: S = "zvvo"
Output: "zvo"
Explanation: Only keep the first
occurrence
Example 2:
Input: S = "gfg"
Output: gf
Explanation: Only keep the first
occurrence
Your task:
Your task is to complete the function removeDups() which takes a single string as input and returns the string. You need not take any input or print anything.
 
Expected Time Complexity: O(|s|)
Expected Auxiliary Space: O(constant)
Constraints:
1 <= |S| <= 10^{5}
S conatins lowercase english alphabets

Difficulty: EASY
Tags: String algorithms

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

Starter code:
#User function Template for python3
class Solution:
	def removeDups(self, S):
		# code here

Solutions:
class Solution:

	def removeDups(self, string):
		p = ''
		for char in string:
			if char not in p:
				p = p + char
		return p


class Solution:

	def removeDups(self, S):
		st_str = []
		n = len(S)
		ans_str = ''
		for ch in S:
			if ch not in st_str:
				ans_str += ch
				st_str.append(ch)
			else:
				pass
		return ans_str


class Solution:

	def removeDups(self, S):
		ans = list(S)
		new_ans = ''
		for i in ans:
			if i not in new_ans:
				new_ans += i
		return new_ans


class Solution:

	def removeDups(self, S):
		seen = set()
		result = ''
		for char in S:
			if char not in seen:
				seen.add(char)
				result += char
		return result


class Solution:

	def removeDups(self, S):
		b = []
		char = list(S)
		for i in range(len(char)):
			if char[i] not in b:
				b.append(char[i])
		c = ''.join(b)
		return c


class Solution:

	def removeDups(self, S):
		str1 = ''
		for i in range(len(S)):
			if S[i] in S and S[i] not in str1:
				str1 = str1 + S[i]
		return str1


class Solution:

	def removeDups(self, S):
		if len(S) == 0 or len(S) == 1:
			return S
		count = [0 for i in range(256)]
		res = ''
		for i in range(len(S)):
			if not count[ord(S[i]) - ord('a')]:
				count[ord(S[i]) - ord('a')] = 1
				res = res + S[i]
		return res


class Solution:

	def removeDups(self, S):
		s = ''
		for i in range(len(S)):
			if S[i] not in s:
				s = s + S[i]
		return s


class Solution:

	def removeDups(self, S):
		s1 = ''
		for i in S:
			if i not in s1:
				s1 += i
		return s1


class Solution:

	def removeDups(self, s):
		r = ''
		for i in s:
			if i not in r:
				r = r + i
		return r


class Solution:

	def removeDups(self, S):
		s = ''
		for i in range(len(S)):
			if S[i] in s:
				continue
			else:
				s = s + S[i]
		return s


class Solution:

	def removeDups(self, S):
		s = []
		for i in S:
			if i not in s:
				s.append(i)
		return ''.join(s)


class Solution:

	def removeDups(self, S):
		seenset = set()
		result = ''
		for ch in S:
			if ch not in seenset:
				seenset.add(ch)
				result = result + ch
		return result


class Solution:

	def removeDups(self, S):
		st_str = []
		ans_st = ''
		for i in S:
			if i not in st_str:
				ans_st += i
				st_str.append(i)
			else:
				continue
		return ans_st


class Solution:

	def removeDups(self, string1):
		answer = ''
		for val in list(string1):
			if val not in answer:
				answer += val
		return answer


class Solution:

	def removeDups(self, S):
		st = []
		ans = ''
		for c in S:
			if c not in st:
				ans += c
				st.append(c)
		return ans


class Solution:

	def removeDups(self, S):
		l = list(S)
		x = []
		for i in l:
			if i not in x:
				x.append(i)
		return ''.join(x)


class Solution:

	def removeDups(self, S):
		l = []
		r = ''
		for i in S:
			if i not in l:
				l.append(i)
		for i in l:
			r += i
		return r


class Solution:

	def removeDups(self, S):
		s = {}
		t = ''
		for i in S:
			if i not in s:
				s[i] = 0
				t = t + i
		return t


class Solution:

	def removeDups(self, S):
		d = []
		n = len(s)
		ans = ''
		for i in S:
			if i not in d:
				ans += i
				d.append(i)
			else:
				pass
		return ans


class Solution:

	def removeDups(self, S):
		S = list(S)
		new_string = ''
		for i in S:
			if i not in new_string:
				new_string += i
		return new_string


class Solution:

	def removeDups(self, S):
		s = set()
		res = ''
		for i in S:
			if i not in s:
				s.add(i)
				res += i
		return res


class Solution:

	def removeDups(self, S):
		res = ''
		for char in S:
			if char not in res:
				res += char
		return res


class Solution:

	def removeDups(self, S):
		a = [0] * 26
		ans = ''
		for i in S:
			if a[ord(i) - 97] == 0:
				ans += i
			a[ord(i) - 97] += 1
		return ans


class Solution:

	def removeDups(self, S):
		l = []
		for i in S:
			if i not in l:
				l.append(i)
		d = ''.join(l)
		return d


class Solution:

	def removeDups(self, S):
		ans = []
		for x in S:
			if x not in ans:
				ans.append(x)
		a = ''.join(ans)
		return a


class Solution:

	def removeDups(self, S):
		str = []
		res = ''
		for ch in S:
			if ch not in str:
				res += ch
				str.append(ch)
			else:
				pass
		return res


class Solution:

	def removeDups(self, S):
		result = ''
		for i in S:
			if i in result:
				pass
			else:
				result += i
		return result


class Solution:

	def removeDups(self, S):
		lst = []
		for i in S:
			if i in lst:
				continue
			else:
				lst.append(i)
		return ''.join(lst)


class Solution:

	def removeDups(self, S):
		st = ''
		length = len(S)
		for i in range(length):
			c = S[i]
			if c not in st:
				st += c
		return st


class Solution:

	def removeDups(self, S):
		x = [0 for i in range(26)]
		for i in range(len(S)):
			x[ord(S[i]) - ord('a')] += 1
		s = ''
		for i in S:
			if x[ord(i) - ord('a')] != 0:
				s += i
				x[ord(i) - ord('a')] = 0
		return s


class Solution:

	def removeDups(self, S):
		arr = []
		for i in S:
			if i not in arr:
				arr.append(i)
		res = ''
		for i in arr:
			res += i
		return res


class Solution:

	def removeDups(self, S):
		sanyam = []
		sanyam1 = ''
		for i in S:
			if i not in sanyam:
				sanyam1 += i
				sanyam.append(i)
			else:
				pass
		return sanyam1


class Solution:

	def removeDups(self, S):
		result = ''
		char_set = [False] * 26
		for ch in S:
			if not char_set[ord(ch) - 97]:
				result += ch
				char_set[ord(ch) - 97] = True
		return result


class Solution:

	def removeDups(self, S):
		l = set(S)
		s = ''.join(S)
		t = ''
		for i in s:
			if i in t:
				pass
			else:
				t = t + i
		return t


class Solution:

	def removeDups(self, S):
		li = []
		for i in S:
			if i not in li:
				li.append(i)
		return ''.join(map(str, li))


class Solution:

	def removeDups(self, S):
		l1 = list(S)
		l2 = []
		for k in l1:
			if k not in l2:
				l2.append(k)
		return ''.join(l2)


class Solution:

	def removeDups(self, S):
		a = []
		str = ''
		for i in S:
			if i not in str:
				str = str + i
		return str


class Solution:

	def removeDups(self, S):
		st = ''
		for i in s:
			if i not in st:
				st += i
		return st


from collections import OrderedDict

class Solution:

	def removeDups(self, S):
		return ''.join(OrderedDict.fromkeys(S))


class Solution:

	def removeDups(self, S):
		st = []
		n = len(S)
		ans = ''
		for ch in S:
			if ch not in st:
				ans += ch
				st.append(ch)
			else:
				pass
		return ans


class Solution:

	def removeDups(self, S):
		a = []
		for i in S:
			if i in a:
				continue
			else:
				a.append(i)
		ans = ''
		for j in a:
			ans = ans + j
		return ans


class Solution:

	def removeDups(self, S):
		s1 = []
		s2 = []
		s3 = []
		s4 = []
		s5 = ''
		for i in s:
			s1.append(i)
		for j in s1:
			s2.append(ord(j))
		[s3.append(x) for x in s2 if x not in s3]
		for k in s3:
			s4.append(chr(k))
		s5 = ''.join(s4)
		return s5


class Solution:

	def removeDups(self, S):
		new = ''
		for a in S:
			if a in new:
				new += ''
			else:
				new += a
		return new


class Solution:

	def removeDups(self, S):
		st = ''
		for i in S:
			if i not in st:
				st += i
			else:
				continue
		return st


class Solution:

	def removeDups(self, S):
		d = dict()
		res = ''
		for i in S:
			if i not in d.keys():
				d[i] = 1
				res += i
		return res


class Solution:

	def removeDups(self, S):

		def remove_duplicates(input_str):
			seen_chars = set()
			output_str = ''
			for char in input_str:
				if char not in seen_chars:
					output_str += char
					seen_chars.add(char)
			return output_str
		return remove_duplicates(S)


class Solution:

	def removeDups(self, S):
		s_list = []
		for i in range(len(s)):
			if s[i] not in s_list:
				s_list.append(s[i])
		return ''.join(s_list)