#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 1e6 + 7;
int n;
int arr[maxn];
int main()
{
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int nLeft = 0, nRight = 0,ret = 0;
set<int> s;
while (nRight < n) {
while (nRight < n && !s.count(arr[nRight])) s.insert(arr[nRight++]);
ret = max(ret, nRight - nLeft);
s.erase(arr[nLeft++]);
}
cout << ret << endl;
}
return 0;
}
07-15
12-25
06-07
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交