Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
      • Data Structures Solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth The Electric Type problem solution

YASH PAL, 31 July 202414 February 2026
In this HackerEarth The Electric Type problem solution 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.
 
 
HackerEarth The Electric Type problem solution

 

 

HackerEarth The Electric Type problem solution.

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
int A[200011];
int main(){

freopen("in01.txt","r",stdin);
freopen("out01.txt","w",stdout);

int N;
cin >> N;
map<int,int>M;
set<int>s;

rep(i,N){
cin >> A[i];
M[A[i]] = i;
s.insert(A[i]);
}

set<int>consider;
for(map<int,int>::iterator it = M.begin();it!=M.end();it++){
consider.insert((*it).s);
}
ll ans = 0;
rep(i,N){
if(consider.count(i)){
ans += s.size();
}
s.insert(A[i]);
}
cout<<ans;

}
 
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes