Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- vector<int> twoSum(vector<int>& nums, int target) {
- unordered_multimap <int, int> m;
- for(int i = 0; i<nums.size(); i++){
- m.insert({nums[i],i});
- }
- for(auto it= m.begin(); it!=m.end(); it++){
- int rem = target - it->first;
- if(m.find(rem)!=m.end() && it->second != m.find(rem)->second){
- return {it->second, m.find(rem)->second};
- }
- }
- return {};
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement