PYTHON:
a=input().strip()
b=[]
for i in a:
if i not in b and a.count(i)>1:
b.append(i)
if(b==[]):
print(-1)
exit()
d=[]
maxi=0
jj=""
for i in b:
c=[]
itera=0
for j in a:
if(j==i):
c.append(itera)
itera+=1
first=min(c)
last=max(c)
if(last-first>maxi):
jj=i
maxi=last-first
print(jj,end="")
print(maxi)
0 Comments