Pairs_on_line doubt

here is the link to my solution


answer given in test case is wrong…my code is giving right answer to the given test case .
when i am submitting the answer its showing wrong answer to all test cases…please help me if i am wrong anywhere.

@ankitkumarmbill1
you don’t need to take unique elements from the array, it is causing error.
In this question you just need to take for pairs like for eg:- (2,2) where first 2 is from 1 and second 2 is also from index 1.
But (2,2) is accepted when first ‘2’ is from some index 1 and second ‘2’ is from index 2.

still after removing the unique line this is my modified code…https://ide.codingblocks.com/s/244242 still its showing wrong answer for all the testcases.

@ankitkumarmbill1
you need to correct some more things in your code:-

  1. You just don’t need to check if y is equal to your current element or not, what exactly you need to check is the pair (Ai, Aj) you are getting in that i != j, bcoz the value can be equal but the element should be different.
  2. Also the given array can contain duplicates, so for eg arr[] = 2,3,3,3,5 so here there can be three pairs of (2,3), so add all.

Don’t need to do much changes in the code, you can have a look at corrected code of yours if you need https://ide.codingblocks.com/s/244769

@ankitkumarmbill1
Feel free to ask you have any confusing in explanation.
Also please mark the doubt as resolved if you understood it now.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.