Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test case for Pair with Target Sum (easy) #4

Open
anchitbhuhan opened this issue Nov 27, 2022 · 1 comment
Open

Failing test case for Pair with Target Sum (easy) #4

anchitbhuhan opened this issue Nov 27, 2022 · 1 comment

Comments

@anchitbhuhan
Copy link

https://dvpr.gitbook.io/coding-interview-patterns/2.-pattern-two-pointers/2.1-pair-with-target-sum-easy#:~:text=int%5B%5D%20copyArray,return%20result%3B

This code does not work for following examples

  • When there are duplicates in the array.
    [2,5,5,11]
    10

Actual Output: [2,2]
Expected output : [1,2]

@ngarg19
Copy link

ngarg19 commented Oct 11, 2023

@anchitbhuhan we have to make sure to iterate our index after comparing one variable. Also we can introduce a check i.e. arr[i] != arr[i+1].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants