| 1 | #include<bits/stdc++.h> |
| 2 | using namespace std; |
| 3 | int main( ) |
| 4 | { |
| 5 | int t;//to store the number of test cases |
| 6 | cin>>t; |
| 7 | for(int p=0;p<t;p++) |
| 8 | { |
| 9 | int n;//to store the number of dolls |
| 10 | cin>>n; |
| 11 | int arr[n];//creating an array |
| 12 | for(int i=0;i<n;i++) |
| 13 | cin>>arr[i];// entering the array elements |
| 14 | sort(arr,arr+n);// sorting the array in ascending order |
| 15 | if(arr[0]!=arr[1])//checking if the first two dolls are in pair |
| 16 | cout<<arr[0]<<endl;//the doll that is missing |
| 17 | else if(arr[n-1]!=arr[n-2])//checking if the last two dolls are in pairs |
| 18 | cout<<arr[n-1]<<endl;//the doll that is missing |
| 19 | else |
| 20 | { |
| 21 | /*to check if all the in-between dolls are in pairs*/ |
| 22 | for(int i=2;i<n-2;i++) |
| 23 | if(arr[i]==arr[i+1]) |
| 24 | i++; |
| 25 | else |
| 26 | { |
| 27 | cout<<arr[i]<<endl;//the doll that is missing |
| 28 | break; |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | return 0; |
| 33 | } |
nothing calls this directly
no outgoing calls
no test coverage detected