标签:logs sub htable rac tar ring for without char
class Solution { public: int lengthOfLongestSubstring(string s) { int hashTable[255]; fill(hashTable, hashTable+255, -1); int start = 0, maxLen = 0; for(int i=0; i<s.size(); ++i) { if(hashTable[s[i]] >= start) { maxLen = max(maxLen, i-start); start = hashTable[s[i]]+1; } hashTable[s[i]] = i; } return max(maxLen, (int)s.size()-start); } };
Longest Substring Without Repeating Characters
标签:logs sub htable rac tar ring for without char
原文地址:http://www.cnblogs.com/chengyuz/p/7040921.html