UNINUM-Editorial

PROBLEM LINK: https://www.codechef.com/COOW2019/problems/UNINUM
DIFFICULTY: Cake-walk
PREREQUISITES: Nothing
EXPLANATION:
We just have to iterate from r to l (both inclusive) and find the value of (r-i)*(i-l) and keep track of maximum of this value and for which number it is maximum.
SOLUTION:
(Python 3)

def check(i):
    d={}
    for j in str(i):
        if j not in d:
            d[j]=1
        else:
            return False
    return True        

l,r=map(int,input().split())
m=-1
ind=-1
for i in range(r,l-1,-1):
    if check(i) and (r-i)*(i-l)>m:
        m=(r-i)*(i-l)
        ind=i
print(ind)