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,...


-

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容