$\textrm{Problem Description : }$$\href{https://leetcode.cn/problems/median-of-two-sorted-arrays/}{\textrm{LeetCode4-寻找两个正序数组的中位数}}$

给定两个有序数组,求两个数组整体的中位数,要求时间复杂度为$O(\log (m+n))$

$\textrm{Solution:}$

对于双有序数组的合并,常常使用双指针的方式,时间复杂度为$O((m+n))$

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;
    }
};

$\textrm{Author}$@$\href{http://kuroko.info}{\textrm{Kuroko}}$

$\textrm{GitHub}$@$\href{https://github.com/SuperKuroko}{\textrm{SuperKuroko}}$

$\textrm{LeetCode}$@$\href{https://leetcode-cn.com/u/kuroko177/}{\textrm{kuroko177}}$

$\textrm{Last Modified: 2023-02-17 16:18}$