repeated-substring

Given a String(only lower case letters) , check if any substring has occured Twice :

 Example : iwsagoodboody
Here, substring  "ood" occurs twice.

Output "YES"  if there is any such substring else output "NO" .(without qoutes)

Input:

First line of input consists of an integer T (1 ≤ T ≤ 100) ,  indicating the number of test cases. 
For each test case, there will be a string s (1 ≤ |s| ≤ 2000)

Output:
    Print "YES"  if there is any such substring else Print "NO" .(without quotes)

SAMPLE INPUT
3
abcdefghi
dogsbarkatdogs
howtheydo

SAMPLE OUTPUT
NO
YES
YES

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
def subString(s):
	count=0
	for sub in s:
		s=s[:s.find(sub)]+s[s.find(sub)+1:]
		if s.find(sub) >=0:
			count+=1
			break
	if count>0:
		print("YES")
	else:
		print("NO")


	pass
if __name__ == '__main__':
	t=int(input())
	for i in range(t):
		s=input()
		subString(s)


t=int(input())
i=0
while i<t:
	s=input()
	if len(set(s))==len(s):
		print("NO")
	else:
		print("YES")

	i+=1


mdict = {}
for test in range(eval(input())):
	flag = 0
	mstr = input()
	for val in mstr:
		x = mstr.count(val)
		if x >= 2:
			print('YES')
			break
	else:
		print("NO")


for tc in range(eval(input())):
	x=input()
	danger=False
	for i in range(len(x)):
		for j in range(i+1,len(x)+1):
			if(x.count(x[i:j])>=2):
				danger=True
				break
		if(danger):
			break
	if(danger):
		print("YES")
	else:
		print("NO")


for tc in range(eval(input())):
	x=input()
	danger=False
	for i in x:
		if(x.count(i)>=2):
			danger=True
			break
	if danger:
		print("YES")
	else:
		print("NO")


for i in range(int(eval(input()))):
	x=input()
	x=list(x)
	for j in range(len(x)):
		l=x.count(x[j])
		if l>=2:
			print("YES")
			break
	if l==1:
		print("NO")