https://leetcode.com/problems/longest-substring-without-repeating-characters

class Solution(object):
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
# convert l into a list of s
# r is a 接收list
# c is the count of highest
        l = list(s)
        r = []
        c = 0

# go through l
# 1. enlarge c if necessary
# 2. pop index 0 to be a
# 3. if a repeat in r, remove everything before a and a, append a again
        while len(l) > 0:
            if len(r) > c:
                c = len(r)

            a = l.pop(0)
            if a in r:
                r = r[r.index(a)+1:]
                r.append(a)
            else:
                r.append(a)
# prevent weird count off
        if len(r) > c:
            c = len(r)

        return c