```
class Solution:
# @return an integer
def lengthOfLongestSubstring(self, s):
d = {}
for i in range(len(s)):
d[(i,i+1)] = True
length = 0
for j in range(2,len(s)):
for i in range(0,len(s)-j):
if d[(i,i+j-1)] and s[i+j-1] not in s[i:i+j-1]:
length = len(s[i:j]) + 1
d[(i,i+j)] = True
else:
d[(i,i+j)] = False
return length
```

My solution is a simple DP , I have cached most of the previous computation result . Why still time exceed limitation?