## 단순 순회

```cpp
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        int i=0,j=1;
        for(i=0;i<j;i++){
            for(j=i+1;j<nums.size();j++){
                if(nums[i]+nums[j]==target){
                    return {i, j};
                }
            }
        }
        return {0, 1};

    }
};
```

- O(n^2)

## stl 사용

```cpp
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> valIdxMap;
        
        for(int idx=0;idx<nums.size();idx++){
            if(valIdxMap.find(target-nums[idx]) != valIdxMap.end()){
                return {idx, valIdxMap[target-nums[idx]]};
            }
            valIdxMap[nums[idx]] = idx;

        }
        return {0, 1};

    }
};
```

- O(nlogn)


