LeetCode刷题——无重复字符的最长子串
生活随笔
收集整理的這篇文章主要介紹了
LeetCode刷题——无重复字符的最长子串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
一、題目描述
二、題解
三、源碼
一、題目描述
?二、題解
三、源碼
?
class Solution(object):def lengthOfLongestSubstring(self, s):""":type s: str:rtype: int"""cur, res = [], 0for r in range(len(s)):while s[r] in cur: cur.pop(0) # 左邊出cur.append(s[r]) # 右側無論如何都會進入新的res = max(len(cur),res)return res總結
以上是生活随笔為你收集整理的LeetCode刷题——无重复字符的最长子串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: new php,PHP: 新特性 - M
- 下一篇: Ubuntu14.04 YouCompl