#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> using ordered_set = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
void setIO(){
freopen("input.txt","r",stdin);
freopen("out.txt","w",stdout);
}
void setIO0(){
freopen("hps.in","r",stdin);
freopen("hps.out","w",stdout);
}
long long mod = 998244353;
long long pow0(long long a,long long b,long long mod){
long long res =1 ;
if(a == 0){
return 1;
}
while(b >0){
if(b&1)
res = (res * a)%mod;
a = (a*a)%mod;
b >>=1;
}
return res;
}
long long fact[501];
long long comb(long long n,long long k){
if(n == 0 || k == 0 || n == k)
return 1;
long long S = fact[n];
S =( S*pow0(fact[n-k],mod-2,mod))%mod;
S =( S*pow0(fact[k],mod-2,mod))%mod;
return S;
}
template <class T> class BIT {
private:
long long size;
vector<T> bit;
vector<T> arr;
public:
BIT(long long size) : size(size), bit(size + 1), arr(size) {}
/** Sets the value at index ind to val. */
void set(long long ind, long long val) { add(ind, val - arr[ind]); }
/** Adds val to the element at index ind. */
void add(long long ind, long long val) {
arr[ind] += val;
ind++;
for (; ind <= size; ind += ind & -ind) { bit[ind] += val; }
}
/** @return The sum of all values in [0, ind]. */
T pref_sum(int ind) {
ind++;
T total = 0;
for (; ind > 0; ind -= ind & -ind) { total += bit[ind]; }
return total;
}
};
struct DSU {
vector<int> e;
DSU(int N) { e = vector<int>(N, -1); }
// get representive component (uses path compression)
int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool same_set(int a, int b) { return get(a) == get(b); }
int size(int x) { return -e[get(x)]; }
bool unite(int x, int y) { // union by size
x = get(x), y = get(y);
if (x == y) return false;
if (e[x] > e[y]) swap(x, y);
e[x] += e[y];
e[y] = x;
return true;
}
};
struct Sqrt {
int block_size;
vector<int> nums;
vector<long long> blocks;
Sqrt(int sqrtn, vector<int> &arr) : block_size(sqrtn), blocks(sqrtn, 0) {
nums = arr;
for (int i = 0; i < nums.size(); i++) {
blocks[i / block_size] += nums[i];
}
}
/** O(1) update to set nums[x] to v */
void update(int x, int v) {
blocks[x / block_size] -= nums[x];
nums[x] = v;
blocks[x / block_size] += nums[x];
}
/** O(sqrt(n)) query for sum of [0, r) */
long long query(int r) {
long long res = 0;
for (int i = 0; i < r / block_size; i++) { res += blocks[i]; }
for (int i = (r / block_size) * block_size; i < r; i++) {
res += nums[i];
}
return res;
}
/** O(sqrt(n)) query for sum of [l, r) */
long long query(int l, int r) { return query(r) - query(l - 1); }
};
int dx[] = {-2,-2,-1,-1,1,1,2,2};
int dy[] = {1,-1,-2,2,-2,2,1,-1};
struct Node{
int a,b;
};
typedef struct Node Node;
void max00(Node& A,Node p , Node q){
if(p.a != q.a){
if(q.a> p.a){
swap(q.a,p.a);
swap(p.b,q.b);
}
A.a = p.a;
A.b = p.b;
}
else{
A.a = p.a;
A.b = p.b+q.b;
}
}
int n,m;
vector<vector<int>> adj, adj_rev;
vector<bool> used;
vector<int> order, component;
vector<int> ct;
void dfs1(int v) {
used[v] = true;
for (auto u : adj[v])
if (!used[u])
dfs1(u);
order.push_back(v);
}
void dfs2(int v) {
used[v] = true;
component.push_back(v);
for (auto u : adj_rev[v])
if (!used[u])
dfs2(u);
}
const int MAX0 = 8e5;
long long seg[MAX0];
long long arr[MAX0],arr1[MAX0];
void build(int id ,int st ,int ed){
if(st == ed){
seg[id] = arr[st];
return;
}
int mid = st + (ed-st)/2;
build(2*id,st , mid);
build(2*id+1,mid+1,ed);
seg[id] = __gcd(seg[2*id],seg[2*id+1]);
}
void update(int id , int st,int ed , int pos){
if(st == ed){
seg[id] = arr[pos];
return;
}
int mid = st + (ed-st)/2;
if(pos <= mid )
update(2*id,st,mid,pos);
else
update(2*id+1,mid+1,ed,pos);
seg[id] = min(seg[2*id],seg[2*id+1]);
}
long long query(int id, int st, int ed , int l , int r){
if(st >= l && ed <= r){
return seg[id];
}
if(r < st || l > ed){
return 0;
}
int mid = st + (ed-st)/2;
long long l0 = query(2*id,st,mid,l,r);
long long r0 = query(2*id+1,mid+1,ed,l,r);
return __gcd(l0,r0);
}
bool cmp(string s, string f){
for(int i = 0; i < min(s.size(),f.size()) ; i++){
if(s[i] == f[i]){
continue;
}
return s[i]>f[i];
}
return s.size() >= f.size();
}
string ct0(string s, string f){
string ans;
for(int i = 0; i < min(s.size(),f.size()) ; i++){
if(s[i] != f[i])
break;
ans += s[i];
}
return ans;
}
//^
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
setIO();
#endif
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> v(n);
map<int,int> mp;
int max0 = 0;
int a = -1;
for(int i = 0; i < n ; i++){
cin>>v[i];
mp[v[i]]++;
if(mp[v[i]] > max0){
max0 = mp[v[i]];
a = v[i];
}
}
sort(v.begin(),v.end());
if(max0 >( n/2 + n%2)){
cout<<-1<<endl;
continue;
}
else if(max0 == n/2+n%2 && a != v[0] && a != v[n-1]){
cout<<-1<<endl;
continue;
}
if(a == v[n-1])
reverse(v.begin(),v.end());
vector<int> ans(n);
int k = 0;
for(int i = 0; i < n ; i+= 2){
ans[i] = v[k];
k++;
}
for(int i = 1; i < n ; i += 2){
ans[i] = v[k];
k++;
}
for(int i = 0; i < n ; i++){
cout<<ans[i]<<" ";
}cout<<endl;
}
}
in Concussive Sequence they say i failed this test case
Input
1
4
1 1 2 2
My Output
1 2 1 2
How i failed this one ???
and can anyone tell give me a test case where this code faild