educative.io

[Two Pointer] Does this problem assume a single solution? Possibility of multiple solutions

Looking at the first example.

Input: [1, 2, 3, 4, 6], target = 6
Output: [1, 3]

What if the array was [0, 1, 2, 3, 4, 5, 6]? Possible solutions could be [0 + 6], [1 + 5], [2 + 4]. Even without the leading zero, [1 + 5] and [2 + 4] are two possible solutions. Can we assume that the input arrays yield one possible solution? Are the numbers in the array carefully selected so that there can only be one solution?

Can we also assume that there are no repeated numbers and that each number only appears once? For example, having two or more 3s in the array will yield another possible solution (3+3).

Hello @Jeremy1

Unless otherwise stated, there exists only one valid solution. If there are more than one valid solution in the test cases, it will be mentioned inside the problem statement or the constraints of the problem statement. The same logic applies for repeated numbers. There are no repeated numbers unless otherwise stated.

Hope this helps!

Cool, thanks for the clarification!