Q:

Print first element of a string array which occurs one time

I have an array with names and I need to print out the first name which only occurs once. For example, I have the following names: 
Joe, Andy, Albert, Andy, Tyler, Albert.
The program Should print out Joe (if there is no correct answer, then print out an empty line), because that is the first one which occurs once.
Here is my program so far: 
#include <iostream>

using namespace std;

int main()
{
int size;
cin >> size;
string trash;

string arr[size];

for (int i=0; i<size; i++)
{
    cin >> arr[i];
}

getline(cin,trash);

string first;
for (int i=0; i<size; i++)
{
   if ( arr[i] != arr[i+1] )
    first = arr[i];
}

cout << first << endl;
}

A:

Here is my version:
#include <iostream>
using namespace std;
int main()
{
int size;
cin >> size;
// string trash;
string arr[size];
for (int i=0; i<size; i++){
    cin >> arr[i];
}
// getline(cin,trash);
string first;
for (int i=0; i<size; i++)
{
    first = arr[i];
    for (int j = 0; j < size; ++j){
        if ( arr[i] == arr[j] && i!=j)
            first = "";
    }
    if (first == arr[i])
        break;
}

cout << first << endl;
}

