Find Pair

2.5

11 votes
Basic Programming, Open, Approved, Easy, Hash function, Mathamatics
Problem

Given an array A having N elements. Find total number of pairs (i,j) such that j < i and Aj = Ai.

Input:

First line of input contains N, size of array A. Next line contains N space separated elements of array A.

Output:

Print the required answer.

Constraints:

1 ≤ N ≤ 105
0 ≤ Ai ≤ 105

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?