美文网首页Leetcode
Leetcode - 3. Longest Substring

Leetcode - 3. Longest Substring

作者: KkevinZz | 来源:发表于2017-03-22 10:43 被阅读0次

    Examples:

    Given"abcabcbb", the answer is"abc", which the length is 3.

    Given"bbbbb", the answer is"b", with the length of 1.

    Given"pwwkew", the answer is"wke", with the length of 3. Note that the answer must be asubstring,"pwke"is asubsequenceand not a substring.


    非常typical 的题目,但是用暴力解法会超时(for pyhton only tough....damn python....)

    暴力解法:

    从第一个开始,check  这个字母是否出现在重复,没有的话counter+=1,else全部归零,把counter和上个最大值进行对比保留最大,java或者c应该就不会超时,python。。。。u know,...

    -

    相关文章

      网友评论

        本文标题:Leetcode - 3. Longest Substring

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