标签:
1 class Solution { 2 public: 3 int lengthOfLongestSubstring(string s) { 4 int len = s.length(), m = 0, l = 0, p[256] = { 0 }; 5 for(int i = 0; i < len; ) { 6 l = max(l, p[s.at(i)]); 7 p[s.at(i)] = ++i; 8 m = max(m, i - l); 9 } 10 return m; 11 } 12 };
};
Longest Substring Without Repeating Characters 7 lines with c++ in 12ms
标签:
原文地址:http://www.cnblogs.com/-chaos/p/4634667.html