Skip to content

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

@aashishpokhrel27

Description

@aashishpokhrel27

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.

class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
for i in range(len(numbers)):
num2 = target - numbers[i]
if num2 in numbers:
return [i + 1, numbers.index(num2) + 1]

This solution though doesn't work if we have duplicate numbers in the List; but in the Neetcode it passed all the test cases, I tried the same solution in the Leetcode but there it fails that particular test case.

Image

The above attached solution is from the Neetcode where it clears all the test case and got accepted.

Image

The above attached solution is from the Leetcode where it doesn't clear all the test case.

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