无重复字符串

思路:一个temp字符串,暂存当前字符串,速度不优,继续改
碰到重复就停下,temp为最长字符串,从下一个开始继续搜索,新temp为temp.find(s[i])+1到temp最后一位,当满足字符串长度大于当前最长字符串长度时,存字符串长度及字符串。

class Solution {
public:
 int lengthOfLongestSubstring(string s) {
        string result="",temp="";
        int max=0;
     int i=0;
     if(s!=" "){
         while(imax)
                    max=temp.length();
              
            } 
            else {
                string tempp=temp;
                temp="";
                for(int j= tempp.find(s[i])+1;j

你可能感兴趣的:(无重复字符串)