Skip to content

Commit

Permalink
100% score solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole committed Jan 12, 2017
1 parent f5a5a7d commit 7d6677f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Lesson2-OddOccurrencesInArray
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int solution(vector<int> &A)
{
map<int, int> mapa;
for( int i = 0; i < A.size(); ++i )
{
mapa[ A.at(i) ]++;
if(mapa[ A.at(i) ] == 2 )
mapa.erase( A.at(i) );
}

return (*mapa.begin()).first;
}

int main(int argc, char *argv[])
{
vector<int> input = {42, 1000000000, 42};
solution( input );
}

0 comments on commit 7d6677f

Please sign in to comment.