美文网首页
2020-02-25 Day3 Leetcode:3. Long

2020-02-25 Day3 Leetcode:3. Long

作者: YueTan | 来源:发表于2020-02-25 08:53 被阅读0次
    1. Longest Substring Without Repeating Characters
      Given a string, find the length of the longest substring without repeating characters.
    class Solution:
        def lengthOfLongestSubstring(self, s: str) -> int:
            if len(s)==0:
                return 0
            max_out=1
            i,j=0,1
            while j<len(s):
                for index in range(i,j):
                    if s[j]==s[index]:
                        i=index+1         
                
                max_out=max(max_out,j-i+1)
                j=j+1
            return max_out
          
                
            
    

    相关文章

      网友评论

          本文标题:2020-02-25 Day3 Leetcode:3. Long

          本文链接:https://www.haomeiwen.com/subject/jhhzqhtx.html