[双指针、模拟]最长连续不重复子序列
模拟即可(
#include <iostream>
using namespace std;
const int maxn = 2e5 + 10;
int n, a[maxn];
int vis[maxn];
int main() {
scanf("%d", &n);
int l = 1, r = 0, ans = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
r++;
vis[a[r]]++;
while (l < r && vis[a[r]] > 1) {
vis[a[l]]--;
l++;
}
ans = max(ans, r - l + 1);
//for (int i = l; i <= r; i++) printf("%d ", a[i]); printf("\n");
}
printf("%d", ans);
return 0;
}