origin free shipping for any purchase.# Fashion - 美丽时尚
s*r
1 楼
脑子短路,看不出来问题。。。
Leetcode online prolem.
Longest Substring Without Repeating Characters
class Solution {
public:
int lengthOfLongestSubstring(string s) {
//e.g. a b c d a e d
int N = s.size();
if (N <= 1) return N;
int i = 0, j = 0;
unordered_set dict; // table
int maxLen = 0;
while (j < N) {
if (dict.find(s[j]) != dict.end()) { //find duplicate
maxLen = max(maxLen, j-i);
dict.clear(); //reset table
i = j;
} else {
dict.insert(s[j]);
++j;
}
}
maxLen = max(maxLen, j-i);
return maxLen;
}
};
Leetcode online prolem.
Longest Substring Without Repeating Characters
class Solution {
public:
int lengthOfLongestSubstring(string s) {
//e.g. a b c d a e d
int N = s.size();
if (N <= 1) return N;
int i = 0, j = 0;
unordered_set
int maxLen = 0;
while (j < N) {
if (dict.find(s[j]) != dict.end()) { //find duplicate
maxLen = max(maxLen, j-i);
dict.clear(); //reset table
i = j;
} else {
dict.insert(s[j]);
++j;
}
}
maxLen = max(maxLen, j-i);
return maxLen;
}
};