I have tried my best to write atleast partial code. need your help in predicting logic missing in my below code. Help me in modifing my code.
This code is the link of this following question : Find longest substring without repeating characters (LeetCode)
code :
input 1 : "pwwkew"
input 2 : "abcabcbb"
input 3 : "cdd"
input 4 : "abcabcbb"
s = "abcabcbb"
temp = ''
cnt = 0
for i in range(len(s)):
if s[i] not in temp:
temp = temp + s[i]
else:
temp = temp.replace(temp[:temp.index(s[i])],'')
print(temp)
Explain me in detail what i am missing as logic ?