Can we solve the question by sorting the given array

like first if we solve the given array we get
1 1 1 2 3 3 3

then we write code like
sort(arr ,arr+n);
int i=0;
while( i<n)
{
if(arr[i]==arr[i+1]==arr[i+2])
{

i=i+3;
}
else
{
cout<<a[i];
break;
}
}

what is wrong in it please answer this this doubt it create confusion

ur logic is correct.
while accessing index make sure i , i+1 ,i+2 should not be greater than or equal to n.

i.e i<n && i+1<n && i+2<n

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.