C++it was their simple twosum bullshyt. Was trying to come up with some samurai-type ninja solution with O(n) or better complexity
Code:std::vector<int> twoSum( std::vector<int>& nums, int target ) { std::vector<int> indices; std::map<int, int> diff_map; std::size_t idx = 0; std::for_each(nums.begin(), nums.end(), [&](int value) { diff_map.insert({target-value, idx++}); }); for (unsigned int n = 0; n < nums.size(); n++) { if (diff_map.find(nums[n]) != diff_map.end()) { if (n != diff_map[nums[n]]) { indices.push_back(n); indices.push_back(diff_map[nums[n]]); return indices; } } } return { 0 }; }
I give myself like 30-45 minutes before I give up and look at solutions