#include #include class Solution { public: std::vector twoSum(std::vector& nums, int target) { std::unordered_map num_map; // Stores number and its index for (int i = 0; i < nums.size(); ++i) { int complement = target - nums[i]; if (num_map.find(complement) != num_map.end()) { return {num_map[complement], i}; // Found the two indices } num_map[nums[i]] = i; // Store index of the current number } return {}; } };