Skip to content

Bug Report for two-integer-sum-ii #5628

@psrinivasan9128

Description

@psrinivasan9128

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions