标签:turn open har alt 滑动 ams display == cli
要求
思路
实现
1 class Solution{ 2 public: 3 int lenthOfLongestSubstring(string s){ 4 int freq[256] = {0}; 5 int l = 0, r = -1; 6 int res = 0; 7 8 while(l < s.size()){ 9 if( r + 1 < s.size() && freq[s[r+1]] == 0) 10 freq[s[++r]] ++ ; 11 else 12 freq[s[l++]] -- ; 13 res = max(res, r-l+1); 14 } 15 return res; 16 } 17 };
相关
[刷题] LeetCode 3 Longest Substring Without Repeating Character
标签:turn open har alt 滑动 ams display == cli
原文地址:https://www.cnblogs.com/cxc1357/p/12596462.html