:type s: str :rtype: int
(self, s)
| 26 | |
| 27 | class Solution(object): |
| 28 | def lengthOfLongestSubstring(self, s): |
| 29 | """ |
| 30 | :type s: str |
| 31 | :rtype: int |
| 32 | """ |
| 33 | if not s: |
| 34 | return 0 |
| 35 | |
| 36 | longestSubstringLength = 1 |
| 37 | |
| 38 | new = s[0] |
| 39 | |
| 40 | for data in s[1:]: |
| 41 | if data not in new: |
| 42 | new += data |
| 43 | continue |
| 44 | |
| 45 | # repeated. |
| 46 | if len(new) > longestSubstringLength: |
| 47 | longestSubstringLength = len(new) |
| 48 | |
| 49 | new = new[new.index(data)+1:] + data |
| 50 | |
| 51 | if len(new) > longestSubstringLength: |
| 52 | return len(new) |
| 53 | |
| 54 | return longestSubstringLength |
nothing calls this directly
no outgoing calls
no test coverage detected