I thought of a solution but I have a doubt if my solution will work.

Please tell your solution of solving it, also a little analysis of the time complexity(if you have time)

Here's the Problem:

Given two arrays of integers A and B of size N each, where each pair (A[i], B[i]) for represents a unique point (x, y) in the 2D Cartesian plane.

Find and return the number of unordered quadruplet (i, j, k, l) such that (A[i], B[i]), (A[j], B[j]), (A[k], B[k]) and (A[l], B[l]) form a rectangle with the rectangle having all the sides parallel to either x-axis or y-axis.

Input Format The first argument given is the integer array A. The second argument given is the integer array 8.

Output Format Return the number of unordered quadruplets that form a rectangle.

Constraints

1<=N<=2000

1<=A[i],B[i]<=10^9

For Example:

Input 1: A=[1,1,2,2] B=[1,2,1,2]

Output 1: 1

Input 2: A=[1,1,2,2,3,3] B=[1,2,1,2,1,2]

Output 2: 3