Leetcode - 3. Longest Substring
2017-03-22 本文已影响0人
KkevinZz
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,...
-