class Solution {
public:
int lengthOfLongestSubstring(string s) {
int strlen = s.length();
int start = 0, len = 0, res;
while(start + len <= strlen){
if(isUnique(&s[start], len)){
//len++;
res = len++;
}
else{
start++;
}
}
return res;
}
private:
bool isUnique(char *s, int len){
map<char, bool> mp;
map<char, bool>::iterator iter;
for(int i = 0; i < len; i++){
iter = mp.find(s[i]);
if(iter == mp.end()){
mp.insert(pair<char, bool>(s[i], true));
}
else{
if(iter->second == true){
return false;
}
else{
iter->second = true;
}
}
}
return true;
}
};