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 Gotta catch ’em all! problem solution

YASH PAL, 31 July 202415 February 2026
In this HackerEarth Gotta catch ’em all! problem solution Little Arihant has always wanted to be the best Pokemon trainer in this world. And he thinks he has achieved his goal, so he wants to quickly go and meet Professor Oak and verify this fact. But like all Pokemon trainers, he has a weird habit, too. He catches Pokemons which can go through evolution to become a better one. After roaming in the Pokeworld for days, he has finally managed to catch k such Pokemons.
 
The way he can make a Pokemon go through evolution is NOT by making them fight battles, but by using an evolution stone. Since he has k Pokemons, he naturally needs k evolution stones for every one of them, as well.
 
Now it takes little Arihant one complete day, to use the evolution stone on one Pokemon. And for each Pokemon, he knows how many days will they take to evolute after the evolution stone has been used on them.
 
He will go to meet Professor Oak, the very next day, once all his Pokemons have gone through evolution. He can select the order of applying evolution stones as he likes, so he wants to do it in such a way that he gets to meet Professor Oak as soon as possible!
 
 
HackerEarth Gotta catch 'em all! problem solution

 

 

HackerEarth Gotta catch ’em all! problem solution.

#include <bits/stdc++.h>
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0);cout.tie(0); } } _;

#define lct long long int t;cin>>t;while(t--)
#define llin(a) ll a; cin>>a;
#define rep(i,n) for(ll i=0;i<n;i++)

typedef long long int ll;

int main()
{
llin(n);
ll arr[n];
rep(i,n)
cin>>arr[i];

sort(arr,arr+n);

ll cnt=1,buf=arr[n-1];
for(ll i=n-2;i>=0;i--)
{
if(arr[i]<buf)
{
buf--;
cnt++;
}
else
{
cnt++;
buf=arr[i];
}
}
cnt+=buf;
cout<<++cnt<<endl;

}
 

Second solution

from sys import *

n = int(stdin.readline())
a = map(int, stdin.readline().split())
#print a
a = sorted(a, reverse = True)
#print a

print max(i + a[i] + 2 for i in range(n))
 
 
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