问题描述
$\textrm{LeetCode4-寻找两个正序数组的中位数}$
解法
对于双有序数组的合并,常常使用双指针的方式,时间复杂度为$O((m+n))$
cpp code
class Solution {
public:
int lengthOfLongestSubstring(string s) {
bool vis[256] = {false};
int left = 0,right,ans = 0;
for(right = 0;right < s.size();right++)
{
while(vis[s[right]])
vis[s[left++]] = false;
vis[s[right]] = true;
ans = max(ans,right-left+1);
}
return ans;
}
};
Author@Kuroko
GitHub@SuperKuroko
LeetCode@kuroko177
Last Modified: 2023-02-17 16:21