标签:
1 class Solution 2 { 3 public: 4 int lengthOfLongestSubstring(string s) 5 { 6 int max = 0; 7 string sub = ""; 8 9 for(int i = 0; i < s.size(); i++) 10 { 11 if(string::npos == sub.find(s[i])) 12 sub += s[i]; 13 else 14 sub = sub.substr(sub.find(s[i]) + 1) + s[i]; 15 16 max = max >= sub.length() ? max : sub.length(); 17 } 18 return max; 19 } 20 };
[leetcode] Longest Substring Without Repeating Characters
标签:
原文地址:http://www.cnblogs.com/lxd2502/p/4316081.html