Closed navedrasul closed 1 month ago
LeetCode Support commented: Hello navedrasul,
Thank you for reaching out regarding your concerns with the "Two Sum" problem. The problem statement guarantees that each input will have exactly one solution, which means that there isn't a scenario where there won't be a pair of numbers adding up to the target. Therefore, your implementation accommodating for a return of [-1, -1]
when no valid pairs exist isn't necessary for this problem.
I recommend reviewing the problem constraints carefully, as they specify that only one valid answer exists for the given input. This should help clarify the expected behavior of your solution. If there are other questions or if you'd like further clarification, feel free to reach out. We're here to help!
Best regards, LeetCode Support Team
LeetCode Username
navedrasul
Problem Number, Title, and Link
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
The function should return [-1, -1] when there is no pair whose sum is equal to the given 'target'. Also, there is no constraint for this.
Language Used for Code
TypeScript
Code used for Submit/Run operation
Expected behavior
There was no case covering the case when there is no pair whose sum is equal to the given 'target'. The function should return [-1, -1] in such a case.
Screenshots
No response
Additional context
No response