Grokking-the-Coding-Interview-Patterns-for-Coding-Questions
Grokking-the-Coding-Interview-Patterns-for-Coding-Questions copied to clipboard
Failing test case for Pair with Target Sum (easy)
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]
@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].
@anchitbhuhan In our case, we are not considering duplicates in the input array. You can incorporate @ngarg19's suggestion.