I wanted to solve the problem "TwoSum" with the help of the HashSet. When I try to post the solution, it fails in the second case with the answer [2,0] 
However, when I try to do the same thing шт IDE it returns me the right answer
Code:
std::vector<int> twoSum(std::vector<int>& nums, int target)
{
std::unordered_set<int> mp;
for (auto i = 0; i < nums.size(); ++i)
{
if (auto it = mp.find(target - nums[i]); it == mp.end())
{
mp.emplace(nums[i]);
}
else
{
return {static_cast<int>(std::distance(mp.begin(), it)), i };
}
}
return {};
}
This comes from Leetcode China ,Official Explanation