-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bug Report for https://neetcode.io/problems/two-integer-sum-ii
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
`public class Solution {
public int[] TwoSum(int[] numbers, int target) {
int[] ints = new int[2];
int upperIndex = numbers.Length - 1;
int startIndex = 0;
while (startIndex < numbers.Length)
{
if (startIndex == upperIndex) return ints;
if ((numbers[startIndex] < numbers[upperIndex]) && (numbers[startIndex] + numbers[upperIndex] == target))
{
ints[0] = numbers[startIndex];
ints[1] = numbers[upperIndex];
return ints;
}
if (numbers[startIndex] > numbers[upperIndex])
{
startIndex++;
} else if (numbers[startIndex] < numbers[upperIndex])
{
upperIndex--;
}
}
return ints;
}
}
`
**Last executed test case
Input:
numbers=[2,3,4]
target=6
Your Output:**
[2,4]
Expected output: -- RETURNED BY NEETCODE - this is wrong.
[1,3]