Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long 

void FastCode (){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main() {

    FastCode();

    int tt;
    cin >> tt;
    while(tt--){
       int size;
       cin >> size;
       ll arr[size];
       for (int i = 0 ; i < size ; i++){
           cin >> arr[i];
       }
       sort(arr,arr+size);
       int max  = 0;
       bool flag = 0;
       for (int i = 0  ; i < size ; i++){
           if(arr[i] != arr[i+1]){
               if (max < arr[i])
                   max = arr[i];
              flag = 1;
           }else{
               cout << arr[i]<<" ";
           }
       }
       if (flag)
           cout << max << endl;
    }

}
Copy
To-do List YoussefAbdelhakem
GNU G++17
81 ms
3.0 MB
Wrong Answer