leetcode 3. Longest Substring Without Repeating Characters
2017-01-28 20:21
555 查看
class Solution { public: int lengthOfLongestSubstring(string s) { string now; decltype(now.size()) max = 0; for (auto a : s) { if (now.find(a) == string::npos) { now += a; } else { if (now.size() > max) { max = now.size(); } auto index = now.find(a); now.erase(0, index + 1); now += a; } } if (now.size() > max) { max = now.size(); } return max; } };
相关文章推荐
- LeetCode --- 3. Longest Substring Without Repeating Characters
- leetcode-3. Longest Substring Without Repeating Characters
- [LeetCode] 3. Longest Substring Without Repeating Characters
- leetcode 3. Longest Substring Without Repeating Characters
- LeetCode Python - 3. Longest Substring Without Repeating Characters
- Leetcode——3. Longest Substring Without Repeating Characters
- [LeetCode]3. Longest Substring Without Repeating Characters
- leetcode 练习题 -- 3. Longest Substring Without Repeating Characters
- [LeetCode] 3. Longest Substring Without Repeating Characters
- leetcode3. Longest Substring Without Repeating Characters
- [leetcode]3. Longest Substring Without Repeating Characters
- [LeetCode] 3. Longest Substring Without Repeating Characters
- leetcode 3. Longest Substring Without Repeating Characters
- LeetCode 3. Longest Substring Without Repeating Characters
- leetcode --3. Longest Substring Without Repeating Characters
- [LeetCode]3. Longest Substring Without Repeating Characters
- leetcode 3. Longest Substring Without Repeating Characters
- [LeetCode] 3. Longest Substring Without Repeating Characters
- [LeetCode]3. Longest Substring Without Repeating Characters
- 【Leetcode】3. Longest Substring Without Repeating Characters