C++ Code use the map


  • 0
    G

    '''

    int singleNumber(vector<int>& nums)
    {
    map<int, int>word_count;
    for (auto &i : nums)
    {
    ++word_count[i];
    }
    for (auto j : word_count)
    {
    if (j.second == 1)
    return j.first;
    }
    }'''


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.