Help me in solving DOMINANT2 problem

My issue

include <bits/stdc++.h>
using namespace std;

int main() {
int t,x;
cin>>t;

while(t--){
    cin>>x;
    
    int arr[x];
    
    for(int i=0;i<x;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());

}

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t,x;
	cin>>t;
	
	while(t--){
	    cin>>x;
	    
	    int arr[x];
	    
	    for(int i=0;i<x;i++){
	        cin>>arr[i];
	    }
	    sort(arr.begin(),arr.end());

}

Learning course: Arrays, Strings & Sorting
Problem Link: Dominant Element Practice Problem in Arrays, Strings & Sorting - CodeChef

@gurjar3004
plzz refer the following code for better understanding

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[n];
	    map<int,int> mp;
	    int mx=0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        mp[a[i]]++;
	        mx=max(mx,mp[a[i]]);
	    }
	    int cnt=0;
	    for(auto x:mp)
	    {
	        if(x.second==mx)
	        cnt++;
	    }
	    if(cnt==1)
	    cout<<"YES";
	    else
	    cout<<"NO";
	    cout<<endl;
	}

}