How can I konw the which container is accepted by leetcode?


  • -1
    X

    class Solution {
    public:
    vector<int> twoSum(vector<int> &numbers, int target) {
    vector<int> RetV;
    map<int,int> Htable;
    int i = 0;
    vector<int>::iterator iter;

        for(iter = numbers.begin(); iter != numbers.end(); iter++)
        {
            Htable.insert(pair<int, int>(numbers[i], i + 1));
            i++;
        }
    
        i = 0;
        for(iter = numbers.begin(); iter != numbers.end(); iter++, i++)
        {
            map<int,int>::iterator hashIter = Htable.find(target - *iter);
            if(hashIter != Htable.end() &&  (hashIter->second) != (i + 1) )
            {
                RetV.push_back( i+1 < hashIter->second ? i+1 : hashIter->second );
                RetV.push_back( i+1 > hashIter->second ? i +1 : hashIter->second );
                return RetV;
            }
        }
        return RetV;
    }
    

    };


Log in to reply
 

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