educative.io

Educative

The test case in not correct?

This test case gives a result of multiple integers, so it’s no longer a twosum question ?


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5724822843686912
Lesson: https://www.educative.io/collection/page/5642554087309312/5724822843686912/5683972000448512

2 Likes

Hey @Yuanbo!
There can be multiple sets of 2 integers whose sum is n, but you are required to return only one such pair, not all pairs.
We hope Educative has inspired you to further your learning. Thank you.

The task explicitly says “returns an array of two integers”.
In the provided test case findSum([9, 4, 7, 2, 6], 17) the expected output is wrong and should be [0, 0]

1 Like

Hi @Evgeny_Mironenko, Thank you for pointing this out.
We really appreciated that you have shared your thoughts with us and explained them very well. It is great seeing that you guys are always coming up with betterments. We’ve looked into it, and concluded that the example is perfectly fine and it should be as it is because it is said in the question that if An array with two integers a and b that add up to a given number or the original array in case a pair is not found.
In the second text case, no two pairs appear in an array that gives the sum value of 17 so it returns the array as it is.
The screenshots below may help to understand.


Hope you understand :blush:

1 Like

Hi @Yuanbo , Thank you for pointing this out.
We really appreciated that you have shared your thoughts with us and explained them very well. It is great seeing that you guys are always coming up with betterments. We’ve looked into it, and concluded that the example is perfectly fine and it should be as it is because it is said in the question that if An array with two integers a and b that add up to a given number or the original array in case a pair is not found.
In the second text case, no two pairs appear in an array that gives the sum value of 17 so it returns the array as it is.
The screenshots below may help to understand.


Hope you understand :blush: