标签:代码 ++ pac loading sum dex 技术 targe val
#include <unordered_map>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int> &nums, int target) {
vector<int> res_vec;
unordered_map<int, int> value_index_map;
for (int i = 0; i < nums.size(); ++i) {
auto iter = value_index_map.find(target - nums[i]);
if (iter != value_index_map.end()) {
res_vec.emplace_back(iter->second);
res_vec.emplace_back(i);
return res_vec;
}
value_index_map.emplace(nums[i], i);
}
return res_vec;
}
};
标签:代码 ++ pac loading sum dex 技术 targe val
原文地址:https://www.cnblogs.com/zhaoshengwei/p/14652259.html