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 Noor and his pond problem solution

YASH PAL, 31 July 202415 February 2026
In this HackerEarth Noor and his pond problem solution Noor is going fish farming. There are N types of fish. Each type of fish has size(S) and eating factor(E). A fish with eating factor of E, will eat all the fish of size.
 
Help Noor to select a set of fish such that the size of the set is maximized as well as they do not eat each other.
 
 
HackerEarth Noor and his pond problem solution

 

 

HackerEarth Noor and his pond problem solution.

#include <bits/stdc++.h>
using namespace std;

string toZero(int n)
{
string ret;
for(int i = 0; i < 2;i ++) ret.push_back(n%10 + '0'), n/=10;
reverse(ret.begin(), ret.end());
return ret;
}

int main()
{
int t;
cin >>t;
assert(t >= 1 && t <= 3);
while(t--){
int n;
cin >> n;
assert(n >= 1 && n <= 100000);

vector< pair<int,int> > vec;
for(int i = 0; i < n; i ++ ){
int s,e;
cin >> s >> e;
assert(s >= 1 && s <= 1000000000);
assert(e >= 1 && e <= 1000000000);
assert(s > e);
vec.push_back( make_pair(e,1));
vec.push_back( make_pair(s,-1));
}
sort(vec.begin(), vec.end());
int ans = 0, cum = 0;
for(int i = 0; i < vec.size(); i ++){
cum += vec[i].second;
ans = max(ans , cum);
}
cout << ans << endl;
}
}

//}
 
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