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 Alex and Requests problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Alex and Requests problem solution, Alex is working in a firm, where he needs to process requests according to their priority. He has N allocation systems. At any instance, the ith system can process only one request with priority i or above.
 
For each request, on any eligible system, Alex can also terminate the request with less priority than that of the current request, in order to assign the current request to the system. There will be Q incoming requests and he needs to tell whether he can assign a system to each request or not.
 
Alex needs to assign each request to the system optimally, such that he can assign a maximum number of incoming requests. The number of requests (which are already assigned) terminated by Alex, doesn’t matter here.
 
 
HackerEarth Alex and Requests problem solution

 

 

HackerEarth Alex and Requests problem solution.

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
assert(n>=1 && n<=100);
int q;
cin>>q;
assert(q>=1 && q<=1e4);
int cur[105]={0};
while(q--)
{
int x;
cin>>x;
assert(x>=1 && x<=1e5);
int val=min(x,n);bool f=0;
for(int i=val;i>=1;i--)
{
if(cur[i]<x){cur[i]=x;cout<<"YESn";f=1;break;}
}
if(!f)cout<<"NOn";
}
return 0;
}
 
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