模仿ACwing上的查找最长不重复子串的写法,简易哈希

class Solution {
public:
    int maxLength(vector<int>& arr) {
        if(arr.size() <= 1)
            return arr.size();
        int used[100010] = {0};
        int ans = 0;
        for(int i = 0,j = 0;i < arr.size();i++)
        {
            used[arr[i]]++;
            while(j < i && used[arr[i]] > 1)
                used[arr[j++]]--;
            ans = max(ans,i - j + 1);
        }
        return ans;
    }
};