Given a string S, find the largest substring with no repetition i.e. largest substring which contain all unique characters.
def lengthOfSubstring(s):
dic = {}
left = -1
res = 0
for i in range(len(s)):
if s[i] in dic and dic[s[i]] > left:
left = dic[s[i]]
dic[s[i]] = i
res = max(res, i-left)
return res
s = input()
print(lengthOfSubstring(s))
For the above problem to solve , what changes will make the above code work fine.