4th Test case in Array target sum pairs

https://ide.codingblocks.com/s/72869

I have posted this query yesterday too, although at night wasn’t able to post the ide link as there was some error preventing me to post saying the doubt is already resolved. Hence had to repost it now

@krishnamanohar199 hey manohar apply a check before printing the value if(min(arr[i],value)!=max(arr[i],value))

1 Like

Still, the 4th test case is failing

@krishnamanohar199 share your code

@krishnamanohar199 remove else line

1 Like

I didn’t understand how that else line made a difference. The suggestion did work though. Thank you :slight_smile:

@krishnamanohar199 hey Krishna actually the test case for this question is designed in a such a way that the similar value can’t make a pair so for eg
5
5
2
3
4
1
6
1 and 5
2 and 4
3 and 3
if we apply a check that I suggest earlier you will find the 3 and 3 eliminated but you if you apply else block you will find that
a[i] which is 3 and value which is 3 will print because if the condition ‘if’ fails else will automatically come into work
so that why I suggest you to remove else block
hope you will understand

1 Like