#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define speedup ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
namespace modop {
ll madd(ll a, ll b) {
return (a + b) % mod;
}
ll msub(ll a, ll b) {
return (((a - b) % mod) + mod) % mod;
}
ll mmul(ll a, ll b) {
return ((a % mod) * (b % mod)) % mod;
}
ll mpow(ll base, ll exp) {
ll res = 1;
while (exp) {
if (exp % 2 == 1) {
res = (res * base) % mod;
}
exp >>= 1;
base = (base * base) % mod;
}
return res;
}
ll minv(ll base) {
return mpow(base, mod - 2);
}
ll mdiv(ll a, ll b) {
return mmul(a, minv(b));
}
const ll FACTORIAL_SIZE = 1.1e6;
ll fact[FACTORIAL_SIZE], ifact[FACTORIAL_SIZE];
void gen_factorial(ll n) {
fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
for (ll i = 2; i <= n; i++) {
fact[i] = (i * fact[i - 1]) % mod;
}
ifact[n] = minv(fact[n]);
for (ll i = n - 1; i >= 2; i--) {
ifact[i] = ((i + 1) * ifact[i + 1]) % mod;
}
}
ll nck(ll n, ll k) {
if (k == 0) {
return 1;
}
ll den = (ifact[k] * ifact[n - k]) % mod;
return (den * fact[n]) % mod;
}
}
using namespace modop;
ll sd(ll a) {
ll res = 0;
while (a) {
ll dig = a % 10;
res += dig;
a /= 10;
}
return res;
}
void solve() {
int n;
cin >> n;
map<int, vector<int>> pos;
vector<int> v(n + 1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
pos[v[i]].push_back(i);
}
vector<int> ans(n + 1, -1);
vector<bool> vis(n + 1);
map<int, int> first;
for (auto x : pos) {
int diff = -1;
int s = x.second.size();
for (int i = 1; i < s; i++) {
diff = max(diff, x.second[i] - x.second[i - 1]);
}
diff = max(diff, n - x.second.back() + 1);
diff = max(diff, x.second.front());
first[x.first] = diff;
}
/*for (auto x : first) {
cout << x.first << " " << x.second << endl;
}*/
for (auto x : first) {
int now = x.second;
while (now <= n and !vis[now]) {
vis[now] = 1;
ans[now] = x.first;
now++;
}
}
for (int i = 1; i <= n; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
int main() {
speedup;
int t;
cin >> t;
while (t--) {
solve();
}
}
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |