Pairs on line dp

why this code is not giving any output.
in this, my logic is to store the count of similar points in a map
and corresponding to each point which has not been visited yet I calculate the total possibility and mark that point as visited
code

Hi @avinashmallik2017 , your visited should be a map intead of a vector and your code is not giving any output as your vector is not initialized
also i did’nt understand your logic for using visited as there is no need for that
let me provide you with a slight variation in your logic:
as all u need to do is consider a[i] as y and storing the frequency in a map in one loop and taking a[i] as x then calculating y from x and checking if we have the y in our given array which we can do using the map.find() function
if yes then there will be two cases

  1. if y is same as x
    then we will have to add freq[y]-1 to the answer (-1 for the case i==j)
  2. if y is different then x
    then simply add freq[y] in your ans

here i have updated your code :- https://ide.codingblocks.com/s/207988