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 Mark The Answer problem solution

YASH PAL, 31 July 202414 February 2026
In this HackerEarth Mark, The Answer problem solution Our friend Monk has an exam that has quite weird rules. Each question has a difficulty level in the form of an Integer. Now, Monk can only solve the problems that have difficulty levels less than X . Now the rules are-
 
  1. A score of the student is equal to the maximum number of answers he/she has attempted without skipping a question.
  2. The student is allowed to skip just “one” question that will not be counted in the continuity of the questions.
 
 
HackerEarth Mark The Answer problem solution

 

 

HackerEarth Mark The Answer problem solution.

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,d;
cin>>n>>d;

bool flag=false;
int ans=0;
vector<int> vec(n);
for(int i=0;i<n;i++)
cin>>vec[i];
for(int i=0;i<n;i++)
{
if(vec[i]>d)
{
if(flag==false)
{
flag=true;
continue;
}
else
{
break;
}
}
else
{
ans++;
}
}
cout<<ans<<endl;
return 0;
}
 

Second solution

n,d = map(int,raw_input().split(' '))
assert(n >= 1 and n <= 10**5 and d >= 1 and d <= 10**9)
a = map(int,raw_input().split(' '))
for i in range(0,n):
assert(a[i] >= 1 and a[i] <= 10**9)
prev = 0
curr = 0
i = 0
while i < n and a[i] <= d:
prev+=1
i+=1
i+=1
while i < n and a[i] <= d:
curr+=1
i+=1
print prev+curr
 
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