Pairs on Line Doubt

How to approach this question??

Hello @Ankit003,

  1. If you have not studied hashing yet:

Find all the possible pair of elements of the array
use to for loops:
i. outer loop will iterate from i=0 to n-1(index of array)
ii. inner loop will iterate from j=i+! to n-1
this is the pair (A[i],A[j]).
Now, use the formula y=mx+c
check for both y=A[i], x=A[j] and y=A[j], x=A[i].
if after putting x into m*x+c, the value is equal to y.
Then, it is one of the possible pair.
Hence, increment count.

  1. if you have done hashmap.
    Try to use it.

Hope, this would help.
Give a like if you are satisfied.