class Solution { public: bool uniqueOccurrences(vector& arr) { int size = arr.size(); // key: number, value: occurrence std::map map1; std::set set1; // create the map for(int i=0; i::iterator itr; itr = map1.begin(); while(itr != map1.end()){ // if this number of occurrence already exists if(set1.find(itr->second) != set1.end()){ return false; } // otherwise, store it. set1.insert(itr->second); itr++; } return true; } };