Leetcode - 3. Longest Substring Without Repeating Characters

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 Without Repeating Characters》

    原文作者:KkevinZz
    原文地址: https://www.jianshu.com/p/a4c71884ab27
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞