I have narrowed down the root cause to the for loop. In the working solution(2nd one below), `for ( int i = k +1; i < nums.size(); ++i)`

works , **but** in the non-working solution (1st one below) `for ( i; i < nums.size(); ++i)`

doesn't. I don't understand why however and was hoping for an explanation.

**The below solution I created works in 15/16 test cases**

```
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int k = 0;
int i = 1;
vector <int> result;
for (k; k < nums.size(); k++) {
int temp = nums[k];
for ( i; i < nums.size(); i++) {
if (( temp + nums[i]) == target) {
result.push_back(k);
result.push_back(i);
return result;
}
}
i = 1;
}
}
};
```

**The below solution I created woks in 16/16(All) test cases**

```
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int k = 0;
int i = 1;
vector <int> result;
for (k; k < nums.size(); k++) {
int temp = nums[k];
for (int i = k + 1; i < nums.size(); i++) {
if (( temp + nums[i]) == target) {
result.push_back(k);
result.push_back(i);
return result;
}
}
}
}
};
```