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
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth The Normal Type problem solution

YASH PAL, 31 July 202415 February 2026
In this HackerEarth The Normal Type problem solution There are a lot of Poke’mons who are jealous of the fact that they do NOT have any specialty, they’re the… normal type of Poke’mon. But, what they fail to realize is that their power is their normalcy, the ability to think, rationalize and then act.
 
But, they do have an additional power… Poke’mons like Jigglypuff – which are normal, can figure out if a trainer is real or is a part of Team Rocket. And they need to use their power to a great extent.
 
In an array, which consists of N elements, A1, A2, …, AN, if a subarray has the total number of distinct elements as that of the original array, that determines the presence of Team Rocket.
 
You’ve to help the normal type Poke’mons in figuring out the total number of subarrays having total number of distinct elements same as that of the original array.
 
 
HackerEarth The Normal Type problem solution

 

 

HackerEarth The Normal 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 f first
#define s second
#define pi pair<ll, ll>
#define pii pair<pi,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define maxn 3000001
int A[200011];
int main(){
freopen("in10.txt","r",stdin);
freopen("out10.txt","w",stdout);
int N;
cin >> N;
set<int>parent;
rep(i,N){
cin >> A[i];
parent.insert(A[i]);
}

ll ans=0;
set<int>s;
int j=0;
map<int,int>M;
rep(i,N){
j=max(j,i);
while(j<N and s.size()<parent.size()){
M[A[j]]++;
if(M[A[j]]==1){
s.insert(A[j]);
}
j++;
}
if(s.size()==parent.size())
ans+=N-j+1;
M[A[i]]--;
if(M[A[i]]==0) s.erase(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