All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

The Electric Type
Tag(s):

Data Structures, Easy-Medium, Map, Set

Problem
Editorial
Analytics

Everyone knows that some special Pikachus hate evolving into Raichus. (The legend says because Raichu is ugly, and Pikachu looks good!)

The question is how do we find these special Pikachus who hate evolution? The crazy Poke'mon trainer Ash Catch'Em has derived a random algorithm, which is completely wrong, but since he's your friend, you've to humor him and his crazy algorithms.

He thinks if you are given $$N$$ Pikachus in an array, A1,A2 ... AN, where each Pikachu is denoted by an integer. The total number of unique pairs (Ai,Aj) where i < j is the number of Pikachus who hate evolution.

Input format:
The first line will consist of a single integer $$N$$. The second line consists of $$N$$ integers A1,A2 ... AN.

Output format:
Output the total number of unique pairs (Ai,Aj) that can be formed, which will also be the number of special Pikachus.

Constraints:
1 ≤ $$N$$ ≤ 2 * 105
1 ≤ $$A$$i ≤ 109

Reference:
enter image description here

SAMPLE INPUT
5
1 2 2 1 3
SAMPLE OUTPUT
6
Explanation

All the possible pairs are (1,1),(1,2) , (1,3) , (2,1), (2,2), (2,3).

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

September Easy '16

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications