Suddenly found that my solution is similar to https://discuss.leetcode.com/topic/4083/shortest-o-n-dp-solution-with-explanations/2.

So posted my solution to share.

```
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
start, dic, maxLen = 0, {}, 0
for i, v in enumerate(s):
if v in dic:
start = max( start, dic.get(v)+1)
maxLen = max(maxLen, i - start + 1)
dic[v] = i
return maxLen
```