xsquare-and-double-strings-1

Xsquare got bored playing with the arrays all the time. Therefore, he has decided to play with the strings. Xsquare called a string P a "double string" if string P is not empty and can be broken into two strings A and B such that A + B = P and A = B. for eg : strings like "baba" , "blabla" , "lolo" are all double strings whereas strings like "hacker" , "abc" , "earth" are not double strings at all.

Today, Xsquare has a special string S consisting of lower case English letters. He can remove as many characters ( possibly zero ) as he wants from his special string S. Xsquare wants to know , if its possible to convert his string S to a double string or not.

Help him in accomplishing this task.

 Note : 
Order of the characters left in the string is preserved even after deletion of some characters.
 Input : 
First line of input contains a single integer T denoting the number of test cases. First and the only line of each test case contains a string S denoting Xsquare's special string.

Output : 
For each test case, print "Yes" if it is possible to convert the given string to a double string. Print "No" otherwise.

 Constraints : 

1 ≤ T ≤ 100
1 ≤ |S| ≤ 100
String |S| consists of lower case english alphabets only.

 SAMPLE INPUT
5
wow
tata
a
ab
lala



SAMPLE OUTPUT
Yes
Yes
No
No
Yes


Explanation

TestCase 1 : "ww" can be obtained by removing 'o' from "wow".
TestCase 2 : "tata" is already a double string.
TestCase 3 : "a" cannot be converted to a double string.
TestCase 4 : "ab" cannot be converted to a double string.
TestCase 5 : "lala" is already a double string.

Difficulty: EASY
Tags: Fundamentals

Ad-hoc

Starter code:

Solutions:
for i in range(eval(input())):
	a=input()
	s=""
	for j in range(0,len(a)):
		if(a[j] not in s):
			s+=a[j]
	if(len(a)==len(s)):
		print('No')
	else:
		print('Yes')


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())

while(t>0):
	flag=0
	s=input()
	size=len(s)
	for i in range(size):
		for j in range(i+1,size):
			if s[i]==s[j]:
				print("Yes")
				flag=1
				break
		if flag==1:
			break
	if flag==0:
	    print("No")
	t-=1		
	


test = input();
test = int(test);
for i in range(0,test):
	element = input();
	check_list = []
	brchr = 0
	for j in range(0,26):
		check_list.append(0);
	for k in element:
		num = ord(k) - 97;
		check_list[num] = check_list[num] + 1;
		if check_list[num] > 1:
			print("Yes");
			brchr = 1
			break;
	if(brchr == 0):
		print("No");


	


test=int(input())
for i in range(0,test):
	st=input()
	i=0
	count=0
	while i<len(st):
		#print(st[i],st[i+1:])
		if st[i] in st[(i+1):]:
			count+=1
			break
		else:
			i+=1
			#print(i)
	if count==0:
		print("No")
	elif count>0:
		print("Yes")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t= int(input())

for i in range(t):
	flag=0
	st= input()
	length= len(st)
	for j in range(length):
		for k in range(j+1,length):
			if st[j]==st[k]:
				print("Yes")
				flag=1
				break
		if flag==1:
			break
		
	else:
		print("No")


def isDoubleStr(txt):
	for i in range(len(txt)):
		if txt.find(txt[i], i+1) > 0:
			txt = txt.replace(txt[i], '$', 2)
	return txt.count('$') > 0		


for _ in range(int(input())):
	print("Yes" if isDoubleStr(input()) else "No")


t=int(eval(input()))
while t:
	t=t-1
	flag=0
	x=input()
	for i in range(len(x)):
		for j in range(i+1,len(x)):
			if x[i]==x[j]:
				print("Yes")
				flag=1
				break
		if flag==1:
			break
	if flag==0:
		print("No")


no = eval(input())
v = []
for i in range(no):
	d = {}
	a = input()
	for j in a:
		d[j]=a.count(j)
	if(max(d.values())>1):
		v.append("Yes")
	else:
		v.append("No")
for e in v:
	print(e)


def double_string(S):
	l=len(S)
	A={}
	flag =False
	for i in range(0,26):
		A[i]=0
	for i in range(0,len(S)):
		A[ord(S[i])-97]+=1
	for i in range(0,26):
		if A[i] >= 2:
			flag=True
			break
	if flag==False:
		return "No"
	else:
		return "Yes"
			
		



T=eval(input())
while(T!=0):
	S=input()
	
	if len(S)<=1:
		print("No")
	
	else:
		status=double_string(S)
		print(status)
	T-=1


for i in range(eval(input())):
	s=input()
	st=set(s)
	f=0
	for each in st:
	   if(s.count(each)>=2):
		   f=1
		   break
	if(f):
		print('Yes')
	else:
		print('No')


# /he/2015/April/Awesome/DBLSTR

n_tests = eval(input())
for tc in range(n_tests):
	inpstr = input()
	chmap = [0] * 26
	found = False
	for ch in inpstr:
		chmap[ord(ch) - ord('a')] += 1
		if chmap[ord(ch) - ord('a')] >= 2:
			print('Yes')
			found = True
			break

	if not found:
		print('No')


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = int(input())
for _ in range(T):
	s = list(input())
	st = set(s)
	flag= False
	for ch in st:
		if s.count(ch)>1:
			flag = True
			break
	print("Yes" if flag else "No")
	


T = int(input())

for tc in range(T):
	S = input().strip()

	NoMatch = True
	for i, chr1 in enumerate(S):
		for chr2 in S[i + 1 :]:
			if chr1 == chr2:
				NoMatch = False
				print('Yes')
				break
		if not NoMatch:
			break
	if NoMatch:
		print('No')




T = int(input())

for i in range(T):
	inp = input()
	dict_ = {x:inp.count(x) for x in inp if inp.count(x)>1}
	# dict_ = [x for x in dict_ if dict_[x] % 2 == 0]
	if len(dict_) >0:
		print("Yes")
	else:
		print("No")


_ = eval(input())

while _>0:
	_ -= 1
	
	s = input()
	l = len(s)
	if l>26:
		print('Yes')
	elif len(set(s))==l:
		print('No')
	else:
		print('Yes')
	


t=int(input())
while t!=0:
	t-=1
	a=input()
	b=list(a)
	b.sort()
	s=""
	for i in b:
		s+=i
	flag=0	
	g=""
	for i in range(len(a)-1):
		for j in range(i+1,len(a)):
			g=""
			if a[i]==a[j]:
				g=a[i]+a[j]
				if g in s:
					print("Yes")
				else:
					print("No")
				flag=1
				break
		if flag==1:
			break
	else:
		print("No")
			
			


import collections

N = int(input())
for x in range(0,N):
	test_flag = False
	test_string = input()
	test_dict = collections.Counter(test_string)
	for i in test_dict.values():
		if i > 1:
			test_flag = True
	
	if test_flag:
		print("Yes")
	else:
		print("No")
			
	


for _ in range(eval(input())):
	a=input().strip()
	d={}
	for c in a:
		if c not in d:
			d[c]=1
		else:
			d[c]+=1
			print("Yes")
			break
	else:
		print("No")


def hasDupChars(string):
	dict = {}
	for c in string:
		if c in dict:
			print('Yes')
			return
		else:
			dict[c] = 1
	
	print('No')


if __name__ == '__main__':
	
	t = int(input())
	for i in range(t):
		hasDupChars(input())
	


from collections import Counter

n=eval(input())

for i in range(0,n):
	values=list(input())
	a=Counter(values)
	flag = False
	for key in list(a.keys()):
		if a[key]>=2:
			print("Yes")
			flag=True
			break
	if not flag:
		print("No")


T = int(input())
for t in range(T):
	double_string = "No"
	s = input().strip()
	d = {}
	for c in s:
		d[c] = d.get(c, 0) + 1

	for v in list(d.values()):
		if v >= 2:
			double_string = "Yes"
	print(double_string)


tc = input()

def checkSpecial(val):
	for i in set(val):
		if val.count(i) > 1:
			return 'Yes'
	return 'No'

for i in range(int(tc)):
	print(checkSpecial(input()))
	


def getres(s):
	if getcount(s):
		print("Yes")
	else:
		print("No")

"""def isdstring(s):
	if len(s) <= 0:
		return False
	else:
		if s[:len(s)/2:] == s[len(s)/2::]:
			return True
"""
def getcount(s):
	count = 0
	dic = {}
	for mem in s:
		if mem in dic:
			dic[mem] = dic[mem] + 1
		else:
			dic[mem] = 1
	#print dic
	for mem1 in dic:
		if dic[mem1] > 1:
			return True
	else:
		return False




t = int(input())
for mem in range(t):
	s = str(input())
	getres(s)
	#getcount(s)


from collections import Counter
t=eval(input())
while t:
	t=t-1
	v='No'
	a=input()
	z=list(Counter(a).values())
	for i in z:
		if(i>1):
			v='Yes'
			break              	
	print(v)


from collections import Counter
for _ in range(int(input())):
	s=Counter(input())
	f=0
	for i in list(s.values()):
		if i>1:
			f=1
			break
	if f:
		print("Yes")
	else:
		print("No")