I'm a beginner in programming. And I'm trying to write code in Python. When I tried to solve the "longest substring without repeating characters", my code failed at a case of "s='bbbbb'".
it said the output was 3 and the expected answer was 1.
However, I tried my code in my own idle, it did show the answer was 1.
I was totally confused. (T-T)
If anyone would like to help me, I will be very appreciated. Thank you!
Here is my code:
def lengthOfLongestSubstring(self, s):
for i in range(len(s)):
if s[i] not in t:
if (len(s)-1-i)>max(t1): for k in range(i): if s[k]==s[i]: t= Solution.lengthOfLongestSubstring(self,s[k+1:]) return max(t1)