Bharath and his strings
Problem link: Codechef
Bharath loves to roam the
campus of NITW and also he is good at problem-solving. Pratyush decided to give
a problem to Bharath.
Pratyush gives Bharath a list of places inside NITW (each place is represented
by some character from 'a' to 'z'). Starting from the beginning, Bharath has to
visit all the places in the same order as given in the list.
While roaming Bharath writes the name of a place when he visits it for the
first time. At the end of the day, Bharat will tell all the distinct places
traveled by him during the entire day in the order he visited them.
Input
First-line will contain T, the number
of test cases. The description of T test cases follows.
The first and only line of each test case contains a string S (containing only
lowercase alphabets).
Output
For each test case print the
order of visit of Bharath.
Constraints
·
1 <= T <= 10
·
1 <= |S| <= 100000
Example
Input:
3
abbcccppf
abaabccba
ccbaacfddhll
Output:
abcpf
abc
cbafdhl
Solution:
t=int(input())
while(t>0):
t-=1
s=input()
l=[]
for i in s:
if i not in l:
l.append(i)
print("".join(l))
Comments
Post a Comment