Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerEarth Mark The Answer problem solution

YASH PAL, 31 July 2024
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

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
©2025 Programming101 | WordPress Theme by SuperbThemes