cbangchen
11/11/2018 - 7:24 AM

1. Two Sum - DifficultyEasy - 2018.9.18

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int c) {
        map<int, int> intMap;
        vector<int> re;
        for (int i = 0; i < nums.size(); i++) {
            if (intMap[nums[i]] != 0) {
                re.push_back(intMap[nums[i]]-100);
                re.push_back(i);     
            }
            intMap[c - nums[i]] = i+100;
        }
        return re;
    }
};