```
#define max 100000
class Solution {
public:
int temp,i,k,last;
int index_next;
bool ref_array[max];
std::vector<int> result;
vector<int> twoSum(vector<int>& nums, int target) {
for(i=0; i<nums.size(); i++)
{
temp=target-nums[i];
if(abs(temp) >= 0 && ref_array[abs(temp)] == 1)
{
last=target-nums[i];
while(nums[k]!=last)
{
k++;
index_next=k;
}
result.push_back(index_next+1);
result.push_back(i+1);
}
ref_array[abs(nums[i])] = 1;
}
return result;
}
};
```