# Given a string, find the length of the longest substring
# without repeating characters.

# Examples:

# Given "abcabcbb", the answer is "abc", which the length is 3.

# Given "bbbbb", the answer is "b", with the length of 1.

# Given "pwwkew", the answer is "wke", with the length of 3.
# Note that the answer must be a substring,
# "pwke" is a subsequence and not a substring.

def longest_non_repeat(s):
    start, maxlen = 0, 0
    used_char = {}
    for i, char in enumerate(s):
        if char in used_char and start <= used_char[char]:
            start = used_char[char] + 1
        else:
            maxlen = max(maxlen, i-start+1)
        used_char[char] = i
    return maxlen

a = "abcabcdefbb"
print(a)
print(longest_non_repeat(a))

@@ -403,25 +403,327 @@
 at(s
+tring
 ):%0A    
-start, max
+if string is None:%0A        return 0%0A    temp = %5B%5D%0A    max_len = 0%0A    for i in string:%0A        if i in temp:%0A            temp = %5B%5D%0A        temp.append(i)%0A        max_len = max(max_len, len(temp))%0A    return max_len%0A%0Adef longest_non_repeat_two(string):%0A    if string is None:%0A        return 0%0A    start, max_
 len 
@@ -732,25 +732,25 @@
 0, 0%0A    use
-d
+r
 _char = %7B%7D%0A 
@@ -757,16 +757,20 @@
    for i
+ndex
 , char i
@@ -782,16 +782,21 @@
 merate(s
+tring
 ):%0A     
@@ -808,25 +808,25 @@
  char in use
-d
+r
 _char and st
@@ -831,25 +831,25 @@
 start %3C= use
-d
+r
 _char%5Bchar%5D:
@@ -868,25 +868,25 @@
  start = use
-d
+r
 _char%5Bchar%5D 
@@ -918,16 +918,17 @@
      max
+_
 len = ma
@@ -936,21 +936,30 @@
 (max
+_
 len, i
--
+ndex - 
 start
-+
+ + 
 1)%0A 
@@ -968,17 +968,17 @@
      use
-d
+r
 _char%5Bch
@@ -984,16 +984,20 @@
 har%5D = i
+ndex
 %0A    ret
@@ -1004,16 +1004,49 @@
 urn 
+ 
 max
+_
 len%0A%0A
+if __name__ == '__main__':%0A    
 a = 
@@ -1059,16 +1059,20 @@
 cdefbb%22%0A
+    
 print(a)
@@ -1072,16 +1072,20 @@
 rint(a)%0A
+    
 print(lo
@@ -1105,8 +1105,45 @@
 eat(a))%0A
+    print(longest_non_repeat_two(a))%0A

update longest_non_repeat