The submit answer gives me a different answer for test case 124 than running it locally or just the run code button. I thought maybe I was outside of boundaries but I can't find where I would be. Any hint of what I'm doing wrong here would be great.

```
class Solution {
public:
int threeSumClosest(vector<int>& nums, int target) {
sort(nums.begin(), nums.end());
vit i, j, k, n(nums.end());
int curRating(-1), tempVal, retVal;
for(i = nums.begin(); i + 2 != n; i++)
{
for(j = i+1; j + 1 != n; j++){
k = approxBinarySearch((target-*i-*j), j+1, n);
tempVal = abs(*i+*j+*k-target);
if(curRating == -1 || abs(tempVal) < curRating){
curRating = abs(tempVal);
retVal = *i+*j+*k;
}
if(retVal == target){
return retVal;
}
}
}
return retVal;
}
private:
typedef vector<int>::iterator vit;
vit approxBinarySearch(int target, vit start, vit end)
{
if(start == end)
return start;
vit current = start + distance(start,end)/2; //start in the middle, assuming sorted
int direction = *current > target ? -1 : 1;
if(*current == target || current == start || (current + direction) == end)
return current;
while(current != start && current != end && abs(target - *current) > 0)
{
current += direction;
}
if(abs(target - *(current - direction)) < abs(target - *current)){
return (current - direction);
} else {
return current;
}
}
};
```